Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 445887

Summary: Exception occurred during compilation unit conversion: ----------------------... (err_grp: 6e4b7cf5)
Product: z_Archived Reporter: EPP Error Reports <error-reports-inbox>
Component: RecommendersAssignee: EPP Error Reports <error-reports-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: johannes.dorn, marcel.bruch, sewe
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description EPP Error Reports CLA 2014-10-03 10:54:15 EDT
Hello committers,

we received a new error report for Eclipse 4.4.1.M20140925-0400.


General Information:
    anonymous-id:         01c9fb23-7e0d-4f0b-8ada-af4b42b9d715
    eclipse-build-id:     4.4.1.M20140925-0400
    eclipse-product:      org.eclipse.epp.package.standard.product
    operating system:     Linux 3.13.0 (x86_64) - gtk
    java-runtime-version: 1.7.0_67-b01

The following plug-ins were present on the execution stack (*):
    1. org.eclipse.core.runtime_3.10.0.v20140318-2214
    2. org.eclipse.jdt.core_3.10.0.v20140902-0626
    3. org.eclipse.jdt_3.10.0.v20140925-0400
    4. org.eclipse.jdt.ui_3.10.1.v20140817-1500
    5. org.eclipse.recommenders.rcp_2.1.10.v20140917-1244


Error Status:
    code:                   4
    plugin:                 org.eclipse.jdt.core_3.10.0.v20140902-0626
    message:                Exception occurred during compilation unit conversion:
----------------------------------- SOURCE BEGIN -------------------------------------
/**
 * 
 */
package com.importio.automagic.api.service;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.Map;
import java.util.UUID;

import lombok.AccessLevel;
import lombok.SneakyThrows;
import lombok.val;
import lombok.experimental.FieldDefaults;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.runners.MockitoJUnitRunner;

import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.importio.api.AttachmentPlugin;
import com.importio.automagic.api.data.AutoPage;
import com.importio.automagic.api.data.AutoPage.SuggestionStatus;
import com.importio.automagic.api.plugin.dto.AutoPageResponse;
import com.importio.automagic.api.service.dto.AutomagicResponse;
import com.importio.automagic.api.service.dto.Table;
import com.importio.binary.compression.GZipCompressor;
import com.importio.data.Attachment;
import com.importio.json.JsonUtils;
import com.importio.s3.URLSigner;
import com.importio.servlet.ImportioServlet;
import com.importio.test.integrationtest.AbstractIntegrationTest;
import com.importio.test.integrationtest.TestStack;
import com.kusiri.glade.org.eclipse.jetty.client.HttpExchange.ContentExchange;
import com.kusiri.glade.scalarobjectstore.BucketDirectory.NoSuchBucketException;

@RunWith(MockitoJUnitRunner.class)
@FieldDefaults(level=AccessLevel.PRIVATE)
public class AutoPageServiceTest extends AbstractIntegrationTest {

	AutoPageService pageService;
	JsonUtils jsonutils = new JsonUtils();
	
	
	public AutoPageServiceTest() {
		setUsingSearch(true);
	}
	
	@SneakyThrows(NoSuchBucketException.class)
	private static AttachmentPlugin setupAttachmentPluginInTestStack(TestStack stack) {
		stack.setGzip(true);
		URLSigner urlSigner = new URLSigner();
		urlSigner.setAccessKey("AKIAIH6GN3QMKQURWYMA");
		urlSigner.setSecretKey("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");
		urlSigner.init();
		AttachmentPlugin plugin = new AttachmentPlugin(stack.getObjectSearchPlugin(), stack.getDownloadService(), stack.getStore(), stack.getThreadPool(), stack.getThreadPool(), urlSigner);
		plugin.setS3BucketName(AttachmentPlugin.TEST_BUCKET);
		stack.getStore().registerPlugin(plugin);
		return plugin;
	}
	
	@Before
	public void setup() {
		val attachmentPlugin = setupAttachmentPluginInTestStack(getTestStack());
		pageService = new AutoPageService(attachmentPlugin, getTestStack().getStore());
		pageService.start();
	}
	
	@Test
	@SneakyThrows
	public void testSaveAndFetchById() {
		val url = "http://beerintheeveing.com";
		val id = UUID.randomUUID();
		val createdPage = pageService.createNew(url, id, ImportioServlet.LOCALHOST);
		assertNotNull(createdPage.getLastModifiedAt());
		assertEquals(url, createdPage.getUrl());
		assertEquals(id, createdPage.getGuid());
		assertEquals(SuggestionStatus.IN_PROGRESS, createdPage.getStatus());
		val fetchedPage = pageService.getById(id).get();
		assertEquals(createdPage, fetchedPage);
	}

	@Test
	@SneakyThrows
	public void testStoreAutoMagicResponse() {
		val url = "http://beerintheeveing.com";
		val id = UUID.randomUUID();
		val createdPage = pageService.createNew(url, id, ImportioServlet.LOCALHOST);
		assertNotNull(createdPage.getLastModifiedAt());
		assertEquals(url, createdPage.getUrl());
		assertEquals(id, createdPage.getGuid());
		assertEquals(SuggestionStatus.IN_PROGRESS, createdPage.getStatus());
		val automagicResponse = createDummyAutoMagicResponse();
		val testHtmlBytes = "<html></html>".getBytes(Charsets.UTF_8);
		createdPage.setAutomagicTime(1);
		createdPage.setDownloadTime(2);
		val stored = pageService.storeAutoMagicResponse(createdPage, testHtmlBytes, automagicResponse).get();
		assertTrue(stored);
		val fetchedPage = pageService.getById(id).get();
		assertEquals(SuggestionStatus.COMPLETE, fetchedPage.getStatus());
		assertEquals(url, fetchedPage.getUrl());
		assertEquals(1, fetchedPage.getAutomagicTime().intValue());
		assertEquals(2, fetchedPage.getDownloadTime().intValue());
		assertNotNull(fetchedPage.getHtml());
		assertNotNull(fetchedPage.getPageResponse());
		//lastly test the attachments
		byte[] fetchedHtmlBytes = getAttachment(createdPage.getGuid(), fetchedPage.getHtml(), "html");
		assertArrayEquals(testHtmlBytes, fetchedHtmlBytes);
		byte[] fetchedPageResponseBytes = getAttachment(createdPage.getGuid(), fetchedPage.getPageResponse(), "pageResponse");
		val fetchPageResponse = jsonutils.fromByteArray(fetchedPageResponseBytes, AutoPageResponse.class);
		assertEquals(automagicResponse.getDetectedResults(), fetchPageResponse.getDetectedResults());
		//TODO:- test scraper config attachment
	}

	@SuppressWarnings("unchecked")
	private AutomagicResponse createDummyAutoMagicResponse() {
		val automagicResponse = new AutomagicResponse();
		val firstTable = new Table();
		Map<String, Object> rowMap = Maps.newHashMap();
		rowMap.put("column_1", "here be data");
		Map<String, Object> columnMap = Maps.newHashMap();
		columnMap.put("column_1", "STRING");
		firstTable.setColumnInfo(Lists.newArrayList(columnMap));
		firstTable.setResults(Lists.newArrayList(rowMap));
		val detectedResults = Lists.newArrayList(firstTable);
		automagicResponse.setDetectedResults(detectedResults);
		Map<String, Object> firstScraperMap = Maps.newHashMap();
		firstScraperMap.put("config", "here be config");
		automagicResponse.setScraperConfigurations(Lists.newArrayList(firstScraperMap));
		return automagicResponse;
	}
	
	@Override
	protected Class<?>[] getBucketClasses() {
		return (new Class<?>[]{AutoPage.class, Attachment.class});
	}

	@SneakyThrows
	private byte[] getAttachment(UUID pageGuid, UUID attachmentGuid, String attachmentField) {
		final ContentExchange ce = exchangeAndAssertResponseCodeButRetry503(200, "/store/autopage/"+pageGuid+"/_attachment/"+attachmentField+"/"+attachmentGuid, "GET", null, getTestStack().getAdminUserCookie(), "application/json");
		assertEquals("gzip", ce.getResponseFields().getStringField("Content-Encoding"));
		val bytes = new GZipCompressor().decompress(ce.getResponseContentBytes());
		return bytes;
	}
	
}

----------------------------------- SOURCE END -------------------------------------
    fingerprint:            6e4b7cf5
    exception class:        java.lang.IllegalArgumentException
    exception message:      -
    number of children:     0

Topmost Stacktrace:
 java.lang.IllegalArgumentException: null
    at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2845)
    at org.eclipse.jdt.core.dom.ASTConverter.setTypeAnnotationsAndSourceRangeOnArray(ASTConverter.java:3420)
    at org.eclipse.jdt.core.dom.ASTConverter.convertToArray(ASTConverter.java:3166)
    at org.eclipse.jdt.core.dom.ASTConverter.convertType(ASTConverter.java:3628)
    at org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationStatement(ASTConverter.java:3439)
    at org.eclipse.jdt.core.dom.ASTConverter.checkAndAddMultipleLocalDeclaration(ASTConverter.java:458)
    at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1257)
    at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2865)
    at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2723)
    at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:635)
    at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:195)
    at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2958)
    at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1374)
    at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:292)
    at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1209)
    at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:809)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:544)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:537)
    at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:480)
    at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:128)
    at org.eclipse.recommenders.rcp.utils.JdtUtils.findAstNodeFromEditorSelection(JdtUtils.java:589)
    at org.eclipse.recommenders.internal.rcp.JavaElementSelectionService.handleSelectionInEditor(JavaElementSelectionService.java:110)
    at org.eclipse.recommenders.internal.rcp.JavaElementSelectionService.access$1(JavaElementSelectionService.java:105)
    at org.eclipse.recommenders.internal.rcp.JavaElementSelectionService$1.run(JavaElementSelectionService.java:82)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
    

Messages, stacktraces, and nested status objects may be shortened. Please visit 
http://dev.eclipse.org/recommenders/reports/542eb897e4b01fa99444abd2
for the complete error log.

The list of all reported error reports belonging to this error group can be
fetched from http://dev.eclipse.org/recommenders/states/542eb897e4b01fa99444abd3/reports

The Error Log Reporter presents the current processing state of this error to 
new reporters. This state can be updated by modifying the values of this bug.
To update the error log database call the link below after each change made to
this bug report: http://dev.eclipse.org/recommenders/states/542eb897e4b01fa99444abd3/sync


Thank you for caring.
Your friendly error reports bot.


--
* Note: The list of present bundles and their respective versions was
  calculated by package naming heuristics. This may or may not reflect reality.
Comment 1 EPP Error Reports CLA 2014-10-22 16:28:34 EDT

*** This bug has been marked as a duplicate of bug 447585 ***