Status: New
Owner: ----

New issue 681 by [email protected]: ComputationException due to StackOverflowError during injection is hard to track down
http://code.google.com/p/google-guice/issues/detail?id=681

When using Guice on Android, it's relatively easy to construct dependency chains that overflow the available stack. In my testing I was able to do it with a chain of length seven on the Android 2.3 emulator (with similar results on Android 2.2 devices as well).

When this happens, it can be extraordinarily difficult to fix the problem because the error message does not include sufficient information to know what Guice was attempting to construct at the time. For example, see the following for a typical example:

11-01 14:28:30.555 E/AndroidRuntime( 4325): Caused by: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: com.google.inject.internal.util.$ComputationException: java.lang.StackOverflowError 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.FailableCache.get(FailableCache.java:50) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.ConstructorInjectorStore.get(ConstructorInjectorStore.java:49) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.ConstructorBindingImpl.initialize(ConstructorBindingImpl.java:125) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:521) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:847) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:772) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:256) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:205) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:853) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.BoundProviderFactory.notify(BoundProviderFactory.java:44) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:133) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:106) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.Guice.createInjector(Guice.java:95) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.google.inject.Guice.createInjector(Guice.java:83) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at roboguice.RoboGuice.setBaseApplicationInjector(RoboGuice.java:92) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.groupon.GrouponApplication.setGrouponApplicationInjector(GrouponApplication.java:179) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at com.groupon.GrouponApplication.onCreate(GrouponApplication.java:44) 11-01 14:28:30.555 E/AndroidRuntime( 4325): at android.app.Instrumentation.


We can see that there are 12 ComputationExceptions, but we can't see what type was being computed at the time.

We can use the debugger (ala http://code.google.com/p/roboguice/wiki/ComputationExceptionStackOverflow ) to figure out the types, but this process would be significantly easier if the ComputationException message included the type key that was being generated.

--
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en.

Reply via email to