Sync with master

This commit is contained in:
mbhave
2019-11-15 14:50:40 +00:00
3 changed files with 48 additions and 4 deletions
@@ -18,11 +18,18 @@
*/
package org.alfresco.solr.utils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Closeable;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
public abstract class Utils
{
private static final Logger LOGGER = LoggerFactory.getLogger(Utils.class);
/**
* Returns the same input collection if that is not null, otherwise a new empty collection.
* Provides a safe way for iterating over a returned collection (which could be null).
@@ -53,4 +60,41 @@ public abstract class Utils
return null;
}
}
/**
* Silently closes the given {@link Closeable} resource without raising any exception.
* This utility method is specifically useful when we have to close a resource in a lamba statement: since the
* close() method could throw an {@link IOException} the compiler requires an enclosing try / catch block which
* makes the code less readable.
*
* <br/><br/>
* <p>
* <code>
* try { if (resource != null) resource.close } catch (IOException exception) { ... }
* </code>
* </p>
* <br/>
*
* In these contexts a call to this method reduces the amount of code needed:
*
* <br/><br/>
* <p>
* <code>
* silentlyClose(resource);
* </code>
* </p>
*
* @param resource the {@link Closeable} resource we want to silently close.
*/
public static void silentyClose(Closeable resource)
{
try
{
if (resource != null) resource.close();
}
catch(IOException ignore)
{
LOGGER.warn("Unable to properly close the resource instance {}. See the stacktrace below for further details.", resource, ignore);
}
}
}
@@ -23,7 +23,7 @@
<properties>
<dependency.alfresco-data-model.version>8.53</dependency.alfresco-data-model.version>
<dependency.jackson.version>2.10.0</dependency.jackson.version>
<dependency.jackson.version>2.10.1</dependency.jackson.version>
</properties>
<dependencies>
@@ -54,9 +54,9 @@ mybatis-spring-1.2.5.jar http://www.mybatis.org/
chemistry-opencmis-server-support-1.0.0.jar http://chemistry.apache.org/
chemistry-opencmis-server-bindings-1.0.0.jar http://chemistry.apache.org/
quartz-2.3.1.jar http://quartz-scheduler.org/
jackson-core-2.10.0.jar https://github.com/FasterXML/jackson
jackson-annotations-2.10.0.jar https://github.com/FasterXML/jackson
jackson-databind-2.10.0.jar https://github.com/FasterXML/jackson
jackson-core-2.10.1.jar https://github.com/FasterXML/jackson
jackson-annotations-2.10.1.jar https://github.com/FasterXML/jackson
jackson-databind-2.10.1.jar https://github.com/FasterXML/jackson
commons-httpclient-3.1-HTTPCLIENT-1265.jar http://jakarta.apache.org/commons/
spring-aop-5.1.8.RELEASE.jar http://projects.spring.io/spring-framework/
spring-beans-5.1.8.RELEASE.jar http://projects.spring.io/spring-framework/