OrderOfTheBee / ootbee-support-tools

OOTBee Support Tools addon to extend set of administrative tools on Repository- and Share-tier
Other
66 stars 38 forks source link

NullPointerException in CacheBackedChunkedList #216

Open Fikili opened 9 months ago

Fikili commented 9 months ago

BUG

Script executed from JS Console receives NPE. The script doesn't need to contain any Alfresco service. Example of the script:

for (var index = 0; index < 10000; index++) {
    print(index);
}

The issue can be reproduced around value index < 500.

The same script was implemented as common webscript and it runs fine.

Expected behavior

Script will be completed without any problem.

Actual behavior

NullPointerException is thrown.

Steps to reproduce the behavior

Run the script above.

Additional details (analysis so far, log statements, references, etc.)

alfresco.log

...
DEBUG [org.alfresco.repo.jscript.RhinoScriptProcessor.calls] [http-nio-8080-exec-8524] 1d12315a7ea92737b1f849a27a55db84.js End 1372 ms
DEBUG [org.orderofthebee.addons.support.tools.repo.jsconsole.ExecuteWebscript] [http-nio-8080-exec-8524] Caught exception; decorating with appropriate status template
java.lang.NullPointerException
    at org.orderofthebee.addons.support.tools.repo.jsconsole.CacheBackedChunkedList.get(CacheBackedChunkedList.java:81)
    at org.orderofthebee.addons.support.tools.repo.jsconsole.CacheBackedChunkedList.get(CacheBackedChunkedList.java:44)
    at java.base/java.util.AbstractList$Itr.next(AbstractList.java:371)
    at java.base/java.util.AbstractCollection.toArray(AbstractCollection.java:144)
    at java.base/java.util.ArrayList.<init>(ArrayList.java:179)
    at org.orderofthebee.addons.support.tools.repo.jsconsole.JavascriptConsoleScriptObject.getPrintOutput(JavascriptConsoleScriptObject.java:239)
    at org.orderofthebee.addons.support.tools.repo.jsconsole.ExecuteWebscript.executeScriptContent(ExecuteWebscript.java:445)
    at org.orderofthebee.addons.support.tools.repo.jsconsole.ExecuteWebscript.lambda$runWithTransactionIfNeeded$1(ExecuteWebscript.java:359)
    at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:450)
    at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:338)
    at org.orderofthebee.addons.support.tools.repo.jsconsole.ExecuteWebscript.runWithTransactionIfNeeded(ExecuteWebscript.java:353)
    at org.orderofthebee.addons.support.tools.repo.jsconsole.ExecuteWebscript.lambda$runScriptWithTransactionAndAuthentication$0(ExecuteWebscript.java:326)
...

Tell us about your environment

Fikili commented 9 months ago

BTW, similar problem is here: https://hub.alfresco.com/t5/alfresco-content-services-forum/problems-copying-a-document-to-several-userhome/td-p/162082

Fikili commented 9 months ago

Added custom debug messages to capture the problem:

[org.orderofthebee.addons.support.tools.repo.jsconsole.CacheBackedChunkedList] [http-nio-8080-exec-13] Chunk size = 170
[org.orderofthebee.addons.support.tools.repo.jsconsole.CacheBackedChunkedList] [http-nio-8080-exec-13] ChunkKey = (1707482785335, 170)
[org.orderofthebee.addons.support.tools.repo.jsconsole.CacheBackedChunkedList] [http-nio-8080-exec-13] chunkList = null
[org.orderofthebee.addons.support.tools.repo.jsconsole.CacheBackedChunkedList] [http-nio-8080-exec-13] AlfrescoRuntimeException was thrown with = null
[org.orderofthebee.addons.support.tools.repo.jsconsole.ExecuteWebscript] [http-nio-8080-exec-13] Caught exception; decorating with appropriate status template
Fikili commented 9 months ago

The problem seems to be related Alfresco clustering and used cache if the clustering is enabled. If clustering is OFF (alfresco.cluster.enabled=false), DefaultSimpleCache is used and everything works fine. If clustering is ON, HazelcastSimpleCache is used and the problem can be seen.

Fikili commented 8 months ago

After another Alfresco restart, I cannot reproduce the issue. I will monitor the situation and if it doesn't appear in a month, I will close the case.