Bug 377343 - NullPointerException in the C/C++ Projects View on eclipse
startup
diff --git a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
index 7eac2f4..1d943a3 100644
--- a/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
+++ b/bundles/org.eclipse.e4.core.di/src/org/eclipse/e4/core/internal/di/InjectorImpl.java
@@ -271,10 +271,11 @@
 	}
 
 	private Object internalMake(Class<?> clazz, PrimaryObjectSupplier objectSupplier, PrimaryObjectSupplier tempSupplier) {
-		if (classesBeingCreated.contains(clazz))
-			throw new InjectionException("Recursive reference trying to create class " + clazz.getName()); //$NON-NLS-1$
+		if (shouldDebug && classesBeingCreated.contains(clazz))
+			LogHelper.logWarning("Possible recursive reference trying to create class \"" + clazz.getName() + "\".", null); //$NON-NLS-1$ //$NON-NLS-2$
 		try {
-			classesBeingCreated.add(clazz);
+			if (shouldDebug)
+				classesBeingCreated.add(clazz);
 
 			boolean isSingleton = clazz.isAnnotationPresent(Singleton.class);
 			if (isSingleton) {
@@ -326,7 +327,8 @@
 			}
 			throw new InjectionException("Could not find satisfiable constructor in " + clazz.getName()); //$NON-NLS-1$
 		} finally {
-			classesBeingCreated.remove(clazz);
+			if (shouldDebug)
+				classesBeingCreated.remove(clazz);
 		}
 	}
 
diff --git a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java
index dfbf57f..bca24c2 100644
--- a/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java
+++ b/tests/org.eclipse.e4.core.tests/src/org/eclipse/e4/core/internal/tests/manual/InjectionErrorReportingTest.java
@@ -21,6 +21,7 @@
 import org.eclipse.e4.core.contexts.EclipseContextFactory;
 import org.eclipse.e4.core.contexts.IEclipseContext;
 import org.eclipse.e4.core.di.InjectionException;
+import org.eclipse.e4.core.di.annotations.Creatable;
 
 /**
  * Manual test to observe error reporting. The JUnits in this
@@ -111,6 +112,12 @@
 		}
 	}
 	
+	@Creatable
+	static class InjectedRecursive {
+		@Inject
+		public InjectedRecursive field;
+	}
+
 	/**
 	 * Shows the error message for an unresolved method argument
 	 */
@@ -234,6 +241,31 @@
 		assertTrue(exception);
 	}
 	
+	/**
+	 * Manual test to check error message for recursive object creation
+	 */
+	public void testRecursionError() {
+		IEclipseContext context = EclipseContextFactory.create();
+		boolean exception = false;
+		try {
+			ContextInjectionFactory.make(InjectedRecursive.class, context);
+		} catch (InjectionException e) {
+			basicLog(e);
+			exception = true;
+		}
+		assertTrue(exception);
+		
+		context.set(InjectedRecursive.class, new InjectedRecursive());
+		exception = false;
+		try {
+			ContextInjectionFactory.make(InjectedRecursive.class, context);
+		} catch (InjectionException e) {
+			basicLog(e);
+			exception = true;
+		}
+		assertFalse(exception);
+	}
+
 	private void basicLog(InjectionException e) {
 		e.printStackTrace(System.out);
 	}