rspec/rules/S3032/java/rule.adoc

36 lines
668 B
Plaintext

== Why is this an issue?
Using the standard ``++getClassLoader()++`` may not return the _right_ class loader in a JEE context. Instead, go through the ``++currentThread++``.
=== Noncompliant code example
[source,java]
----
ClassLoader cl = this.getClass().getClassLoader(); // Noncompliant
----
=== Compliant solution
[source,java]
----
ClassLoader cl = Thread.currentThread().getContextClassLoader();
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]