1 package org.neo4j.driver; 2 3 import org.neo4j.driver.exception.Neo4jClientException; 4 5 /** 6 * Wrap an AutoCloseable object for adding the Runnable trait. 7 */ 8 public interface UncheckedCloseable extends Runnable, AutoCloseable { 9 10 /** 11 * Wrap the defined AutoCloseable object. 12 */ 13 static UncheckedCloseable wrap(AutoCloseable c) { 14 return c::close; 15 } 16 17 /** 18 * Default implementation of {@link Runnable#run}. 19 */ 20 default void run() { 21 try { 22 close(); 23 } catch (Exception e) { 24 throw new Neo4jClientException(e); 25 } 26 } 27 }