Author: cziegeler Date: Wed Aug 9 16:11:32 2017 New Revision: 1804571 URL: http://svn.apache.org/viewvc?rev=1804571&view=rev Log: SLING-7040 : Update commons lang 2.x to 3.5
Removed: sling/trunk/bundles/extensions/healthcheck/core/src/test/java/org/apache/sling/hc/api/ sling/trunk/bundles/extensions/healthcheck/core/src/test/java/org/apache/sling/hc/util/ Modified: sling/trunk/bundles/extensions/healthcheck/core/pom.xml sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAdjustableStatusForTesting.java sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/AsyncHealthCheckExecutor.java sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckFuture.java sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/HealthCheckExecutorServlet.java sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultHtmlSerializer.java sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultJsonSerializer.java sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultTxtVerboseSerializer.java sling/trunk/bundles/extensions/healthcheck/core/src/test/java/org/apache/sling/hc/core/it/U.java Modified: sling/trunk/bundles/extensions/healthcheck/core/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/pom.xml?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/pom.xml (original) +++ sling/trunk/bundles/extensions/healthcheck/core/pom.xml Wed Aug 9 16:11:32 2017 @@ -128,11 +128,6 @@ <artifactId>org.osgi.compendium</artifactId> </dependency> <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.scr.annotations</artifactId> - <scope>provided</scope> - </dependency> - <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.hc.api</artifactId> <version>1.0.1-SNAPSHOT</version> @@ -246,9 +241,9 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.5</version> + <groupId>org.apache.commons</groupId> + <artifactId>commons-lang3</artifactId> + <version>3.4</version> <scope>provided</scope> </dependency> Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAdjustableStatusForTesting.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAdjustableStatusForTesting.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAdjustableStatusForTesting.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/JmxAdjustableStatusForTesting.java Wed Aug 9 16:11:32 2017 @@ -35,7 +35,7 @@ import javax.management.MBeanOperationIn import javax.management.MBeanParameterInfo; import javax.management.ReflectionException; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/AsyncHealthCheckExecutor.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/AsyncHealthCheckExecutor.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/AsyncHealthCheckExecutor.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/AsyncHealthCheckExecutor.java Wed Aug 9 16:11:32 2017 @@ -27,7 +27,7 @@ import java.util.Set; import java.util.TreeSet; import java.util.concurrent.ConcurrentHashMap; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -188,12 +188,12 @@ public class AsyncHealthCheckExecutor im checksIt.remove(); } } - + LOG.debug("Caching {} results from async results", asyncResults.size()); for(ExecutionResult result : asyncResults) { cache.updateWith(result); } - + LOG.debug("Adding {} results from async results", asyncResults.size()); results.addAll(asyncResults); Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckExecutorImpl.java Wed Aug 9 16:11:32 2017 @@ -35,7 +35,7 @@ import java.util.ListIterator; import java.util.Map; import java.util.Set; -import org.apache.commons.lang.time.StopWatch; +import org.apache.commons.lang3.time.StopWatch; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; @@ -111,7 +111,7 @@ public class HealthCheckExecutorImpl imp @Reference private AsyncHealthCheckExecutor asyncHealthCheckExecutor; - + @Reference private ThreadPoolManager threadPoolManager; private ThreadPool hcThreadPool; @@ -229,7 +229,7 @@ public class HealthCheckExecutorImpl imp final List<HealthCheckExecutionResult> results = new ArrayList<HealthCheckExecutionResult>(); final List<HealthCheckMetadata> healthCheckDescriptors = getHealthCheckMetadata(healthCheckReferences); - + createResultsForDescriptors(healthCheckDescriptors, results, options); stopWatch.stop(); @@ -258,7 +258,7 @@ public class HealthCheckExecutorImpl imp if (!options.isForceInstantExecution()) { asyncHealthCheckExecutor.collectAsyncResults(healthCheckDescriptors, results, healthCheckResultCache); } - + // reuse cached results where possible if (!options.isForceInstantExecution()) { healthCheckResultCache.useValidCacheResults(healthCheckDescriptors, results, resultCacheTtlInMs); @@ -370,7 +370,7 @@ public class HealthCheckExecutorImpl imp } }); this.stillRunningFutures.put(metadata, future); - + final HealthCheckFuture newFuture = future; this.hcThreadPool.execute(new Runnable() { @Override @@ -378,11 +378,11 @@ public class HealthCheckExecutorImpl imp newFuture.run(); synchronized ( stillRunningFutures ) { // notify executor threads that newFuture is finished. Wrapping it in another runnable - // ensures that newFuture.isDone() will return true (if e.g. done in callback above, there are + // ensures that newFuture.isDone() will return true (if e.g. done in callback above, there are // still a few lines of code until the future is really done and hence then the executor thread - // is sometime notified a bit too early, still receives the result isDone()=false and then waits + // is sometime notified a bit too early, still receives the result isDone()=false and then waits // for another 50ms, even though the future was about to be done one ms later) - stillRunningFutures.notifyAll(); + stillRunningFutures.notifyAll(); } } }); @@ -403,7 +403,7 @@ public class HealthCheckExecutorImpl imp if (options != null && options.getOverrideGlobalTimeout() > 0) { effectiveTimeout = options.getOverrideGlobalTimeout(); } - + if(futuresForResultOfThisCall.isEmpty()) { return; // nothing to wait for (usually because of cached results) } @@ -469,7 +469,7 @@ public class HealthCheckExecutorImpl imp } else { logger.debug("Health Check timed out: {}", hcMetadata); - // Futures must not be cancelled as interrupting a health check might leave the system in invalid state + // Futures must not be cancelled as interrupting a health check might leave the system in invalid state // (worst case could be a corrupted repository index if using write operations) // normally we turn the check into WARN (normal timeout), but if the threshold time for CRITICAL is reached for a certain Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckFuture.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckFuture.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckFuture.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/executor/HealthCheckFuture.java Wed Aug 9 16:11:32 2017 @@ -23,7 +23,7 @@ import java.util.Date; import java.util.concurrent.Callable; import java.util.concurrent.FutureTask; -import org.apache.commons.lang.time.StopWatch; +import org.apache.commons.lang3.time.StopWatch; import org.apache.sling.hc.api.HealthCheck; import org.apache.sling.hc.api.Result; import org.apache.sling.hc.api.execution.HealthCheckExecutionResult; Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/HealthCheckExecutorServlet.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/HealthCheckExecutorServlet.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/HealthCheckExecutorServlet.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/HealthCheckExecutorServlet.java Wed Aug 9 16:11:32 2017 @@ -32,8 +32,8 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.ConfigurationPolicy; @@ -360,7 +360,7 @@ public class HealthCheckExecutorServlet sb.append("<h3>Supported URL parameters</h3>\n"); for(Param p : PARAM_LIST) { sb.append("<b>").append(p.name).append("</b>:"); - sb.append(StringEscapeUtils.escapeHtml(p.description)); + sb.append(StringEscapeUtils.escapeHtml4(p.description)); sb.append("<br/>"); } return sb.toString(); Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultHtmlSerializer.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultHtmlSerializer.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultHtmlSerializer.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultHtmlSerializer.java Wed Aug 9 16:11:32 2017 @@ -26,8 +26,8 @@ import java.util.Date; import java.util.Dictionary; import java.util.List; -import org.apache.commons.lang.StringEscapeUtils; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringEscapeUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Property; @@ -87,13 +87,13 @@ public class ResultHtmlSerializer { List<String> tags = executionResult.getHealthCheckMetadata().getTags(); boolean hasTags = tags != null && tags.size() > 0 && StringUtils.isNotBlank(tags.get(0)); writer.print("<tr class=\"" + getClassForStatus(result.getStatus()) + "\">"); - writer.print("<td><p title=\"" + StringEscapeUtils.escapeHtml(executionResult.getHealthCheckMetadata().getName()) + "\">" - + StringEscapeUtils.escapeHtml(executionResult.getHealthCheckMetadata().getTitle()) + ""); + writer.print("<td><p title=\"" + StringEscapeUtils.escapeHtml4(executionResult.getHealthCheckMetadata().getName()) + "\">" + + StringEscapeUtils.escapeHtml4(executionResult.getHealthCheckMetadata().getTitle()) + ""); if (hasTags) { - writer.println("<br/><span style='color:gray'>" + StringEscapeUtils.escapeHtml(StringUtils.join(tags, ", ")) + "</span>"); + writer.println("<br/><span style='color:gray'>" + StringEscapeUtils.escapeHtml4(StringUtils.join(tags, ", ")) + "</span>"); } writer.println("</p></td>"); - writer.println("<td style='font-weight:bold;'>" + StringEscapeUtils.escapeHtml(result.getStatus().toString()) + "</td>"); + writer.println("<td style='font-weight:bold;'>" + StringEscapeUtils.escapeHtml4(result.getStatus().toString()) + "</td>"); writer.println("<td>"); boolean isFirst = true; @@ -112,15 +112,15 @@ public class ResultHtmlSerializer { boolean showStatus = !isSingleResult && entry.getStatus()!=Result.Status.DEBUG && entry.getStatus() !=Result.Status.INFO; - String message = StringEscapeUtils.escapeHtml(entry.getMessage()); + String message = StringEscapeUtils.escapeHtml4(entry.getMessage()); if(entry.getStatus()==Result.Status.DEBUG) { message = "<span style='color:gray'/>"+message + "</span>"; } - writer.println((showStatus ? StringEscapeUtils.escapeHtml(entry.getStatus().toString()) + " " : "") + message); + writer.println((showStatus ? StringEscapeUtils.escapeHtml4(entry.getStatus().toString()) + " " : "") + message); Exception exception = entry.getException(); if (exception != null) { - writer.println("<span style='width:20px'/>" + StringEscapeUtils.escapeHtml(exception.toString())); + writer.println("<span style='width:20px'/>" + StringEscapeUtils.escapeHtml4(exception.toString())); writer.println("<!--"); exception.printStackTrace(writer); writer.println("-->"); Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultJsonSerializer.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultJsonSerializer.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultJsonSerializer.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultJsonSerializer.java Wed Aug 9 16:11:32 2017 @@ -27,7 +27,7 @@ import javax.json.JsonException; import javax.json.JsonObject; import javax.json.JsonObjectBuilder; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Service; import org.apache.sling.hc.api.Result; @@ -55,11 +55,11 @@ public class ResultJsonSerializer { result.add("overallResult", overallResult.getStatus().toString()); JsonArrayBuilder resultsJsonArr = Json.createArrayBuilder(); - + for (HealthCheckExecutionResult healthCheckResult : executionResults) { resultsJsonArr.add(getJsonForSimpleResult(healthCheckResult, includeDebug)); } - + result.add("results", resultsJsonArr); } catch (JsonException e) { LOG.info("Could not serialize health check result: " + e, e); @@ -67,9 +67,9 @@ public class ResultJsonSerializer { StringWriter writer = new StringWriter(); Json.createGenerator(writer).write(result.build()).close(); - + String resultStr = writer.toString(); - + if (StringUtils.isNotBlank(jsonpCallback)) { resultStr = jsonpCallback + "(" + resultStr + ");"; } @@ -93,7 +93,7 @@ public class ResultJsonSerializer { result.add("tags", tagsArray); JsonArrayBuilder messagesArr = Json.createArrayBuilder(); - + for (ResultLog.Entry entry : healthCheckResult.getHealthCheckResult()) { if (!includeDebug && entry.getStatus() == Result.Status.DEBUG) { continue; @@ -109,9 +109,9 @@ public class ResultJsonSerializer { } messagesArr.add(jsonEntry); } - + result.add("messages", messagesArr); - + return result.build(); } Modified: sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultTxtVerboseSerializer.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultTxtVerboseSerializer.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultTxtVerboseSerializer.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/main/java/org/apache/sling/hc/core/impl/servlet/ResultTxtVerboseSerializer.java Wed Aug 9 16:11:32 2017 @@ -22,8 +22,8 @@ import java.text.SimpleDateFormat; import java.util.List; import java.util.Map; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.WordUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.text.WordUtils; import org.apache.felix.scr.annotations.Activate; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Property; @@ -82,7 +82,7 @@ public class ResultTxtVerboseSerializer public String serialize(final Result overallResult, final List<HealthCheckExecutionResult> executionResults, boolean includeDebug) { LOG.debug("Sending verbose txt response... "); - + StringBuilder resultStr = new StringBuilder(); resultStr.append(StringUtils.repeat("-", totalWidth) + NEWLINE); @@ -134,7 +134,7 @@ public class ResultTxtVerboseSerializer resultStr.append(messageToPrint); resultStr.append(NEWLINE); } - + if (isFirst) { // no log entry exists, ensure newline resultStr.append(NEWLINE); Modified: sling/trunk/bundles/extensions/healthcheck/core/src/test/java/org/apache/sling/hc/core/it/U.java URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/healthcheck/core/src/test/java/org/apache/sling/hc/core/it/U.java?rev=1804571&r1=1804570&r2=1804571&view=diff ============================================================================== --- sling/trunk/bundles/extensions/healthcheck/core/src/test/java/org/apache/sling/hc/core/it/U.java (original) +++ sling/trunk/bundles/extensions/healthcheck/core/src/test/java/org/apache/sling/hc/core/it/U.java Wed Aug 9 16:11:32 2017 @@ -42,12 +42,12 @@ public class U { // the name of the system property providing the bundle file to be installed and tested private static final String BUNDLE_JAR_SYS_PROP = "project.bundle.file"; - + /** Wait until the specified number of health checks are seen by supplied executor */ static void expectHealthChecks(int howMany, HealthCheckExecutor executor, String ... tags) { expectHealthChecks(howMany, executor, new HealthCheckExecutionOptions(), tags); } - + /** Wait until the specified number of health checks are seen by supplied executor */ static void expectHealthChecks(int howMany, HealthCheckExecutor executor, HealthCheckExecutionOptions options, String ... tags) { final long timeout = System.currentTimeMillis() + 10000L; @@ -66,18 +66,18 @@ public class U { } fail("Did not get " + howMany + " health checks with tags " + Arrays.asList(tags) + " after " + timeout + " msec (last count=" + count + ")"); } - + static Option[] config() { final String localRepo = System.getProperty("maven.repo.local", ""); final boolean felixShell = "true".equals(System.getProperty("felix.shell", "false")); - + final String bundleFileName = System.getProperty(BUNDLE_JAR_SYS_PROP); final File bundleFile = new File(bundleFileName); if (!bundleFile.canRead()) { throw new IllegalArgumentException( "Cannot read from bundle file " + bundleFileName + " specified in the " + BUNDLE_JAR_SYS_PROP + " system property" ); } - + // As we're using the forked pax exam container, we need to add a VM // option to activate the jacoco test coverage agent. final String coverageCommand = System.getProperty("coverage.command"); @@ -85,7 +85,7 @@ public class U { return options( when(localRepo.length() > 0).useOptions( systemProperty("org.ops4j.pax.url.mvn.localRepository").value(localRepo) - ), + ), junitBundles(), when(coverageCommand != null && coverageCommand.trim().length() > 0).useOptions( CoreOptions.vmOption(coverageCommand) @@ -120,7 +120,7 @@ public class U { mavenBundle("commons-collections", "commons-collections", "3.2.1"), mavenBundle().groupId("commons-io").artifactId("commons-io").versionAsInProject(), mavenBundle("commons-fileupload", "commons-fileupload", "1.2.2"), - mavenBundle().groupId("commons-lang").artifactId("commons-lang").versionAsInProject() + mavenBundle().groupId("org.apache.commons").artifactId("commons-lang3").versionAsInProject() ) ); }