From 75d986e61f1f34c5982769e05f47a63883f0bf3e Mon Sep 17 00:00:00 2001 From: Julien Ruaux Date: Mon, 15 Aug 2022 02:28:59 -0700 Subject: [PATCH] deps: Added slf4j-jdk14 --- connectors/riot-db/riot-db.gradle | 1 - .../java/com/redis/riot/db/ScriptRunner.java | 13 +- connectors/riot-file/riot-file.gradle | 1 - .../riot/file/resource/XmlItemReader.java | 139 +++++++++--------- core/riot-core/riot-core.gradle | 1 + 5 files changed, 78 insertions(+), 77 deletions(-) diff --git a/connectors/riot-db/riot-db.gradle b/connectors/riot-db/riot-db.gradle index 5e926c71e..2376e0332 100644 --- a/connectors/riot-db/riot-db.gradle +++ b/connectors/riot-db/riot-db.gradle @@ -17,7 +17,6 @@ dependencies { implementation 'org.postgresql:postgresql' implementation group: 'org.xerial', name: 'sqlite-jdbc', version: sqliteVersion testImplementation project(':riot-test') - testImplementation 'org.slf4j:slf4j-simple' testImplementation group: 'org.testcontainers', name: 'postgresql', version: testcontainersVersion testImplementation group: 'org.testcontainers', name: 'oracle-xe', version: testcontainersVersion } diff --git a/connectors/riot-db/src/test/java/com/redis/riot/db/ScriptRunner.java b/connectors/riot-db/src/test/java/com/redis/riot/db/ScriptRunner.java index e534f6691..c4cbf63bd 100644 --- a/connectors/riot-db/src/test/java/com/redis/riot/db/ScriptRunner.java +++ b/connectors/riot-db/src/test/java/com/redis/riot/db/ScriptRunner.java @@ -8,16 +8,15 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Statement; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.util.logging.Level; +import java.util.logging.Logger; /** * Tool to run database scripts */ public class ScriptRunner { - private static final Logger log = LoggerFactory.getLogger(ScriptRunner.class); + private static final Logger log = Logger.getLogger(ScriptRunner.class.getName()); private static final String DEFAULT_DELIMITER = ";"; @@ -84,7 +83,7 @@ private void runScript(Connection conn, Reader reader) throws IOException, SQLEx } String trimmedLine = line.trim(); if (trimmedLine.startsWith("--")) { - log.debug(trimmedLine); + log.fine(trimmedLine); } else if (trimmedLine.length() < 1 || trimmedLine.startsWith("//")) { // Do nothing } else if (trimmedLine.length() < 1 || trimmedLine.startsWith("--")) { @@ -95,7 +94,7 @@ private void runScript(Connection conn, Reader reader) throws IOException, SQLEx command.append(" "); Statement statement = conn.createStatement(); - log.debug(command.toString()); + log.fine(command.toString()); boolean hasResults = false; if (stopOnError) { @@ -104,7 +103,7 @@ private void runScript(Connection conn, Reader reader) throws IOException, SQLEx try { statement.execute(command.toString()); } catch (SQLException e) { - log.error("Error executing: {}", command, e); + log.log(Level.SEVERE, "Error executing: " + command, e); } } diff --git a/connectors/riot-file/riot-file.gradle b/connectors/riot-file/riot-file.gradle index 2b37d9c1f..5e595201e 100644 --- a/connectors/riot-file/riot-file.gradle +++ b/connectors/riot-file/riot-file.gradle @@ -15,7 +15,6 @@ dependencies { implementation (group: 'org.springframework.cloud', name: 'spring-cloud-gcp-starter-storage', version: gcpVersion) { exclude group: 'javax.annotation', module: 'javax.annotation-api' } - testImplementation 'org.slf4j:slf4j-simple' testImplementation project(':riot-test') } diff --git a/connectors/riot-file/src/main/java/com/redis/riot/file/resource/XmlItemReader.java b/connectors/riot-file/src/main/java/com/redis/riot/file/resource/XmlItemReader.java index ef3030950..c6ee94a4b 100644 --- a/connectors/riot-file/src/main/java/com/redis/riot/file/resource/XmlItemReader.java +++ b/connectors/riot-file/src/main/java/com/redis/riot/file/resource/XmlItemReader.java @@ -1,7 +1,7 @@ package com.redis.riot.file.resource; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import java.util.logging.Logger; + import org.springframework.batch.item.ItemStreamReader; import org.springframework.batch.item.file.ResourceAwareItemReaderItemStream; import org.springframework.batch.item.support.AbstractItemCountingItemStreamItemReader; @@ -10,7 +10,8 @@ import org.springframework.util.Assert; /** - * {@link ItemStreamReader} implementation that reads XML objects from a {@link Resource} having the following format: + * {@link ItemStreamReader} implementation that reads XML objects from a + * {@link Resource} having the following format: * *
  * {@code
@@ -28,81 +29,83 @@
  * @author Julien Ruaux
  */
 public class XmlItemReader extends AbstractItemCountingItemStreamItemReader
-        implements ResourceAwareItemReaderItemStream {
+		implements ResourceAwareItemReaderItemStream {
 
-    private static final Log LOGGER = LogFactory.getLog(XmlItemReader.class);
+	private static final Logger LOGGER = Logger.getLogger(XmlItemReader.class.getName());
 
-    private Resource resource;
+	private Resource resource;
 
-    private XmlObjectReader xmlObjectReader;
+	private XmlObjectReader xmlObjectReader;
 
-    private boolean strict = true;
+	private boolean strict = true;
 
-    /**
-     * Create a new {@link XmlItemReader} instance.
-     * 
-     * @param resource the input XML resource
-     * @param xmlObjectReader the XML object reader to use
-     */
-    public XmlItemReader(Resource resource, XmlObjectReader xmlObjectReader) {
-        Assert.notNull(resource, "The resource must not be null.");
-        Assert.notNull(xmlObjectReader, "The XML object reader must not be null.");
-        this.resource = resource;
-        this.xmlObjectReader = xmlObjectReader;
-    }
+	/**
+	 * Create a new {@link XmlItemReader} instance.
+	 * 
+	 * @param resource        the input XML resource
+	 * @param xmlObjectReader the XML object reader to use
+	 */
+	public XmlItemReader(Resource resource, XmlObjectReader xmlObjectReader) {
+		Assert.notNull(resource, "The resource must not be null.");
+		Assert.notNull(xmlObjectReader, "The XML object reader must not be null.");
+		this.resource = resource;
+		this.xmlObjectReader = xmlObjectReader;
+	}
 
-    /**
-     * Set the {@link XmlObjectReader} to use to read and map XML elements to domain objects.
-     * 
-     * @param xmlObjectReader the XML object reader to use
-     */
-    public void setXmlObjectReader(XmlObjectReader xmlObjectReader) {
-        this.xmlObjectReader = xmlObjectReader;
-    }
+	/**
+	 * Set the {@link XmlObjectReader} to use to read and map XML elements to domain
+	 * objects.
+	 * 
+	 * @param xmlObjectReader the XML object reader to use
+	 */
+	public void setXmlObjectReader(XmlObjectReader xmlObjectReader) {
+		this.xmlObjectReader = xmlObjectReader;
+	}
 
-    /**
-     * In strict mode the reader will throw an exception on {@link #open(org.springframework.batch.item.ExecutionContext)} if
-     * the input resource does not exist.
-     * 
-     * @param strict true by default
-     */
-    public void setStrict(boolean strict) {
-        this.strict = strict;
-    }
+	/**
+	 * In strict mode the reader will throw an exception on
+	 * {@link #open(org.springframework.batch.item.ExecutionContext)} if the input
+	 * resource does not exist.
+	 * 
+	 * @param strict true by default
+	 */
+	public void setStrict(boolean strict) {
+		this.strict = strict;
+	}
 
-    @Override
-    public void setResource(Resource resource) {
-        this.resource = resource;
-    }
+	@Override
+	public void setResource(Resource resource) {
+		this.resource = resource;
+	}
 
-    @Nullable
-    @Override
-    protected T doRead() throws Exception {
-        return xmlObjectReader.read();
-    }
+	@Nullable
+	@Override
+	protected T doRead() throws Exception {
+		return xmlObjectReader.read();
+	}
 
-    @Override
-    protected void doOpen() throws Exception {
-        if (!this.resource.exists()) {
-            if (this.strict) {
-                throw new IllegalStateException("Input resource must exist (reader is in 'strict' mode)");
-            }
-            LOGGER.warn("Input resource does not exist " + this.resource.getDescription());
-            return;
-        }
-        if (!this.resource.isReadable()) {
-            if (this.strict) {
-                throw new IllegalStateException("Input resource must be readable (reader is in 'strict' mode)");
-            }
-            LOGGER.warn("Input resource is not readable " + this.resource.getDescription());
-            return;
-        }
-        this.xmlObjectReader.open(this.resource);
-    }
+	@Override
+	protected void doOpen() throws Exception {
+		if (!this.resource.exists()) {
+			if (this.strict) {
+				throw new IllegalStateException("Input resource must exist (reader is in 'strict' mode)");
+			}
+			LOGGER.warning("Input resource does not exist " + this.resource.getDescription());
+			return;
+		}
+		if (!this.resource.isReadable()) {
+			if (this.strict) {
+				throw new IllegalStateException("Input resource must be readable (reader is in 'strict' mode)");
+			}
+			LOGGER.warning("Input resource is not readable " + this.resource.getDescription());
+			return;
+		}
+		this.xmlObjectReader.open(this.resource);
+	}
 
-    @Override
-    protected void doClose() throws Exception {
-        this.xmlObjectReader.close();
-    }
+	@Override
+	protected void doClose() throws Exception {
+		this.xmlObjectReader.close();
+	}
 
 }
diff --git a/core/riot-core/riot-core.gradle b/core/riot-core/riot-core.gradle
index 0a94b2dec..db7cab861 100644
--- a/core/riot-core/riot-core.gradle
+++ b/core/riot-core/riot-core.gradle
@@ -8,5 +8,6 @@ dependencies {
     implementation group: 'me.tongfei', name: 'progressbar', version: progressbarVersion
     implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
     implementation group: 'org.awaitility', name: 'awaitility', version: awaitilityVersion
+    runtimeOnly 'org.slf4j:slf4j-jdk14'
     testImplementation 'org.junit.jupiter:junit-jupiter-engine'
 }
\ No newline at end of file