Code pitfalls code-pitfalls

CAUTION
AEM 6.4 has reached the end of extended support and this documentation is no longer updated. For further details, see our technical support periods. Find the supported versions here.

Avoid Sling Bindings in Java code avoid-sling-bindings-in-java-code

Sling Bindings are an inappropriate way to get access to a service in 90% of cases. Instead, you should use @Reference or @Inject annotations.

Avoid Thread.interrupt in Java code avoid-thread-interrupt-in-java-code

Thread.interrupt is dangerous because it can close files, including Lucene files and persistent cache files, when called at the wrong time.

Avoid mixing Java synchronization with ReadWriteLocks avoid-mixing-java-synchronization-with-readwritelocks

This can lead to a race condition in which the code will eventually deadlock.

recommendation-more-help
2315f3f5-cb4a-4530-9999-30c8319c520e