GeezerVison is showing github.com — chore: replace System.out/printStackTrace with logging · swagger-api/swagger-core@8fcecf9
File treeExpand file treeCollapse file tree Open diff view settings swagger-core/src/main/java/io/swagger/v3/core/util swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/src/main/java/io/swagger/v3/plugin/maven/jakarta
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json.java +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; | 4 | 4 | import com.fasterxml.jackson.databind.ObjectMapper; | 5 | 5 | import com.fasterxml.jackson.databind.ObjectWriter; | | 6 | +import org.slf4j.Logger; | | 7 | +import org.slf4j.LoggerFactory; | 6 | 8 |
| 7 | 9 | public class Json { | 8 | 10 |
| 9 | 11 | private static final class ObjectMapperHolder { | 10 | 12 | private static final ObjectMapper MAPPER = ObjectMapperFactory.createJson(); | 11 | 13 | } | 12 | 14 |
| | 15 | + private static final Logger LOGGER = LoggerFactory.getLogger(Json.class); | | 16 | + | 13 | 17 | public static ObjectMapper mapper() { | 14 | 18 | return ObjectMapperHolder.MAPPER; | 15 | 19 | } | @@ -22,16 +26,16 @@ public static String pretty(Object o) { | 22 | 26 | try { | 23 | 27 | return pretty().writeValueAsString(o); | 24 | 28 | } catch (Exception e) { | 25 | | - e.printStackTrace(); | | 29 | + LOGGER.error("Error serializing object to JSON", e); | 26 | 30 | return null; | 27 | 31 | } | 28 | 32 | } | 29 | 33 |
| 30 | 34 | public static void prettyPrint(Object o) { | 31 | 35 | try { | 32 | | - System.out.println(pretty().writeValueAsString(o).replace("\r", "")); | | 36 | + LOGGER.debug(pretty().writeValueAsString(o).replace("\r", "")); | 33 | 37 | } catch (Exception e) { | 34 | | - e.printStackTrace(); | | 38 | + LOGGER.error("Error pretty-printing JSON", e); | 35 | 39 | } | 36 | 40 | } | 37 | 41 | } |
Collapse file Copy file name to clipboardExpand all lines: modules/swagger-core/src/main/java/io/swagger/v3/core/util/Json31.java +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -21,7 +21,7 @@ private static final class ConverterMapperHolder { | 21 | 21 | private static final ObjectMapper MAPPER = ObjectMapperFactory.createJsonConverter(); | 22 | 22 | } | 23 | 23 |
| 24 | | - static Logger LOGGER = LoggerFactory.getLogger(Json31.class); | | 24 | + private static final Logger LOGGER = LoggerFactory.getLogger(Json31.class); | 25 | 25 |
| 26 | 26 | public static ObjectMapper mapper() { | 27 | 27 | return ObjectMapperHolder.MAPPER; | @@ -39,16 +39,16 @@ public static String pretty(Object o) { | 39 | 39 | try { | 40 | 40 | return pretty().writeValueAsString(o); | 41 | 41 | } catch (Exception e) { | 42 | | - e.printStackTrace(); | | 42 | + LOGGER.error("Error serializing object to JSON (3.1)", e); | 43 | 43 | return null; | 44 | 44 | } | 45 | 45 | } | 46 | 46 |
| 47 | 47 | public static void prettyPrint(Object o) { | 48 | 48 | try { | 49 | | - System.out.println(pretty().writeValueAsString(o).replace("\r", "")); | | 49 | + LOGGER.debug(pretty().writeValueAsString(o).replace("\r", "")); | 50 | 50 | } catch (Exception e) { | 51 | | - e.printStackTrace(); | | 51 | + LOGGER.error("Error pretty-printing JSON (3.1)", e); | 52 | 52 | } | 53 | 53 | } | 54 | 54 |
| |
Collapse file Copy file name to clipboardExpand all lines: modules/swagger-core/src/main/java/io/swagger/v3/core/util/Yaml.java +7-3Lines changed: 7 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 3 | 3 | import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; | 4 | 4 | import com.fasterxml.jackson.databind.ObjectMapper; | 5 | 5 | import com.fasterxml.jackson.databind.ObjectWriter; | | 6 | +import org.slf4j.Logger; | | 7 | +import org.slf4j.LoggerFactory; | 6 | 8 |
| 7 | 9 | public class Yaml { | 8 | 10 |
| 9 | 11 | private static final class ObjectMapperHolder { | 10 | 12 | private static final ObjectMapper MAPPER = ObjectMapperFactory.createYaml(); | 11 | 13 | } | 12 | 14 |
| | 15 | + private static final Logger LOGGER = LoggerFactory.getLogger(Yaml.class); | | 16 | + | 13 | 17 | public static ObjectMapper mapper() { | 14 | 18 | return ObjectMapperHolder.MAPPER; | 15 | 19 | } | @@ -22,16 +26,16 @@ public static String pretty(Object o) { | 22 | 26 | try { | 23 | 27 | return pretty().writeValueAsString(o); | 24 | 28 | } catch (Exception e) { | 25 | | - e.printStackTrace(); | | 29 | + LOGGER.error("Error serializing object to YAML", e); | 26 | 30 | return null; | 27 | 31 | } | 28 | 32 | } | 29 | 33 |
| 30 | 34 | public static void prettyPrint(Object o) { | 31 | 35 | try { | 32 | | - System.out.println(pretty().writeValueAsString(o)); | | 36 | + LOGGER.debug(pretty().writeValueAsString(o)); | 33 | 37 | } catch (Exception e) { | 34 | | - e.printStackTrace(); | | 38 | + LOGGER.error("Error pretty-printing YAML", e); | 35 | 39 | } | 36 | 40 | } | 37 | 41 | } |
Collapse file Copy file name to clipboardExpand all lines: modules/swagger-core/src/main/java/io/swagger/v3/core/util/Yaml31.java +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,7 @@ private static final class ObjectMapperHolder { | 17 | 17 | } | 18 | 18 |
| 19 | 19 |
| 20 | | - static Logger LOGGER = LoggerFactory.getLogger(Yaml31.class); | | 20 | + private static final Logger LOGGER = LoggerFactory.getLogger(Yaml31.class); | 21 | 21 |
| 22 | 22 | public static ObjectMapper mapper() { | 23 | 23 | return ObjectMapperHolder.MAPPER; | @@ -31,16 +31,16 @@ public static String pretty(Object o) { | 31 | 31 | try { | 32 | 32 | return pretty().writeValueAsString(o); | 33 | 33 | } catch (Exception e) { | 34 | | - e.printStackTrace(); | | 34 | + LOGGER.error("Error serializing object to YAML (3.1)", e); | 35 | 35 | return null; | 36 | 36 | } | 37 | 37 | } | 38 | 38 |
| 39 | 39 | public static void prettyPrint(Object o) { | 40 | 40 | try { | 41 | | - System.out.println(pretty().writeValueAsString(o)); | | 41 | + LOGGER.debug(pretty().writeValueAsString(o)); | 42 | 42 | } catch (Exception e) { | 43 | | - e.printStackTrace(); | | 43 | + LOGGER.error("Error pretty-printing YAML (3.1)", e); | 44 | 44 | } | 45 | 45 | } | 46 | 46 |
| |
Collapse file Copy file name to clipboardExpand all lines: modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/OpenApiServlet.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -41,7 +41,7 @@ public void init(ServletConfig config) throws ServletException { | 41 | 41 | .ctxId(ctxId) | 42 | 42 | .buildContext(true); | 43 | 43 | } catch (OpenApiConfigurationException e) { | 44 | | - e.printStackTrace(); | | 44 | + LOGGER.error("Failed to initialize OpenAPI servlet context", e); | 45 | 45 | } | 46 | 46 | } | 47 | 47 |
| |
Collapse file Copy file name to clipboardExpand all lines: modules/swagger-maven-plugin/src/main/java/io/swagger/v3/plugin/maven/IncludeProjectDependenciesComponentConfigurator.java +4-3Lines changed: 4 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -39,8 +39,9 @@ public void configureComponent(Object component, PlexusConfiguration configurati | 39 | 39 | private void addProjectDependenciesToClassRealm(ExpressionEvaluator expressionEvaluator, ClassRealm containerRealm) throws ComponentConfigurationException { | 40 | 40 | List<String> compileClasspathElements; | 41 | 41 | try { | 42 | | - //noinspection unchecked | 43 | | - compileClasspathElements = (List<String>) expressionEvaluator.evaluate("${project.compileClasspathElements}"); | | 42 | + @SuppressWarnings("unchecked") | | 43 | + List<String> evaluated = (List<String>) expressionEvaluator.evaluate("${project.compileClasspathElements}"); | | 44 | + compileClasspathElements = evaluated; | 44 | 45 | } catch (ExpressionEvaluationException e) { | 45 | 46 | throw new ComponentConfigurationException("There was a problem evaluating: ${project.compileClasspathElements}", e); | 46 | 47 | } | @@ -68,4 +69,4 @@ private URL[] buildURLs(List<String> runtimeClasspathElements) throws ComponentC | 68 | 69 | return urls.toArray(new URL[urls.size()]); | 69 | 70 | } | 70 | 71 |
| 71 | | -} | | 72 | +} |
Collapse file Copy file name to clipboardExpand all lines: modules/swagger-project-jakarta/modules/swagger-maven-plugin-jakarta/src/main/java/io/swagger/v3/plugin/maven/jakarta/JakartaTransformer.java +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | package io.swagger.v3.plugin.maven.jakarta; | 2 | 2 |
| | 3 | +import org.slf4j.Logger; | | 4 | +import org.slf4j.LoggerFactory; | | 5 | + | 3 | 6 | import java.io.BufferedInputStream; | 4 | 7 | import java.io.BufferedReader; | 5 | 8 | import java.io.BufferedWriter; | | 42 | 45 | */ | 43 | 46 | public class JakartaTransformer { | 44 | 47 |
| | 48 | + private static final Logger LOGGER = LoggerFactory.getLogger(JakartaTransformer.class); | | 49 | + | 45 | 50 |
| 46 | 51 | /* | 47 | 52 | * Substitution tokens + regex | @@ -212,7 +217,7 @@ public FileVisitResult visitFile(Path file, | 212 | 217 | Files.copy(file, pathInZipfile, options); | 213 | 218 |
| 214 | 219 | } catch (IOException e) { | 215 | | - e.printStackTrace(); | | 220 | + LOGGER.error("Error copying file '{}' into ZIP filesystem", file, e); | 216 | 221 | } | 217 | 222 |
| 218 | 223 | return FileVisitResult.CONTINUE; | |
|