This is an automated email from the ASF dual-hosted git repository.

andysch pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-cpconverter.git


The following commit(s) were added to refs/heads/master by this push:
     new ae0b663  Use a local variable to adjust the bundle name to avoid side 
effects through the loop
ae0b663 is described below

commit ae0b663655203759c216369eccfd62329f9d9e0f
Author: Andreas Schaefer <[email protected]>
AuthorDate: Mon May 13 21:28:32 2019 -0700

    Use a local variable to adjust the bundle name to avoid side effects 
through the loop
    
    The bundleName parameter is changed in the loop with side effects to 
subsequent looping this can lead to picking the wrong entry
---
 .../feature/cpconverter/handlers/BundleEntryHandler.java  | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
 
b/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
index 1e7e3e6..3135a7b 100644
--- 
a/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
+++ 
b/src/main/java/org/apache/sling/feature/cpconverter/handlers/BundleEntryHandler.java
@@ -135,25 +135,26 @@ public final class BundleEntryHandler extends 
AbstractRegexEntryHandler {
                     continue;
                 }
 
-                int idx = bundleName.lastIndexOf('/');
+                String currentName = bundleName;
+                int idx = currentName.lastIndexOf('/');
                 if (idx >= 0) {
-                    bundleName = bundleName.substring(idx + 1);
+                    currentName = currentName.substring(idx + 1);
                 }
 
-                int edx = bundleName.lastIndexOf('.');
+                int edx = currentName.lastIndexOf('.');
                 if (edx > 0) {
-                    bundleName = bundleName.substring(0, edx);
+                    currentName = currentName.substring(0, edx);
                 }
 
                 // bundleName is now the bare name without extension
                 String synthesized = artifactId + "-" + version;
 
                 // it was the pom.properties  we were looking for
-                if (bundleName.startsWith(synthesized)) {
+                if (currentName.startsWith(synthesized)) {
 
                     // check the artifact has a classifier in the bundle file 
name
-                    if (synthesized.length() < bundleName.length()) {
-                        String suffix = 
bundleName.substring(synthesized.length());
+                    if (synthesized.length() < currentName.length()) {
+                        String suffix = 
currentName.substring(synthesized.length());
                         if (suffix.length() > 1 && suffix.startsWith("-")) {
                             String classifier = suffix.substring(1);
                             logger.info("Inferred classifier of '"

Reply via email to