GAE, java 11 flex environment, не удалось создать хук отключения - PullRequest
0 голосов
/ 20 января 2019

У меня есть GAE, который я развертываю, используя гибкую среду с пользовательской средой выполнения (Java 11), все работает хорошо. При добавлении ловушки отключения я провал с этим исключением:

java.lang.NullPointerException: Operation not allowed in a thread that is neither the original request thread nor a thread created by ThreadManager

Полный след:

Unexpected exception occurred invoking async method: public void com.xyz.hooks.shutdown.googleAppEngine.GoogleAppEngineShutDownHook.registerHook()
java.lang.NullPointerException: Operation not allowed in a thread that is neither the original request thread nor a thread created by ThreadManager
    at com.google.appengine.api.LifecycleManager.currentAppVersionId(LifecycleManager.java:92)
    at com.google.appengine.api.LifecycleManager.setShutdownHook(LifecycleManager.java:40)
    at com.xyz.hooks.shutdown.googleAppEngine.GoogleAppEngineShutDownHook.registerHook(GoogleAppEngineShutDownHook.java:29)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
    at org.springframework.aop.interceptor.AsyncExecutionInterceptor.lambda$invoke$0(AsyncExecutionInterceptor.java:115)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:834

мой код:

  LifecycleManager.getInstance().setShutdownHook(() -> {
            shutdownService.flushAll();
        });
...