You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2022/06/01 09:17:15 UTC

[GitHub] [sling-org-apache-sling-testing-sling-mock] stefanseifert commented on a diff in pull request #13: SLING-11362 Prevent potential ClassCastException in tearDown

stefanseifert commented on code in PR #13:
URL: https://github.com/apache/sling-org-apache-sling-testing-sling-mock/pull/13#discussion_r886579516


##########
core/src/main/java/org/apache/sling/testing/mock/sling/context/SlingContextImpl.java:
##########
@@ -217,9 +217,9 @@ private void registerInjectActivateServiceByClassName(@NotNull String @NotNull .
     protected void tearDown() {
 
         if (this.request != null) {
-            MockSlingBindings slingBindings = (MockSlingBindings)this.request.getAttribute(SlingBindings.class.getName());
-            if (slingBindings != null) {
-                slingBindings.tearDown();
+            SlingBindings slingBindings = (SlingBindings)this.request.getAttribute(SlingBindings.class.getName());
+            if (slingBindings != null && slingBindings instanceof MockSlingBindings) {

Review Comment:
   sonarcube reports: Remove this unnecessary null check; "instanceof" returns false for nulls.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org