Skip to content

Commit

Permalink
WW-5458 Replaces e.printStackTrace() with proper logger
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszlenart committed Sep 7, 2024
1 parent 74c01b3 commit 81a3776
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.opensymphony.xwork2.conversion.ObjectTypeDeterminer;
import ognl.OgnlException;
import ognl.OgnlRuntime;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Map;

Expand All @@ -31,6 +33,8 @@
*/
public class MockObjectTypeDeterminer implements ObjectTypeDeterminer {

private static final Logger LOG = LogManager.getLogger(MockObjectTypeDeterminer.class);

private Class keyClass;
private Class elementClass;
private String keyProperty;
Expand Down Expand Up @@ -69,10 +73,9 @@ public String getKeyProperty(Class parentClass, String property) {
public boolean shouldCreateIfNew(Class parentClass, String property,
Object target, String keyProperty, boolean isIndexAccessed) {
try {
System.out.println("ognl:"+OgnlRuntime.getPropertyAccessor(Map.class)+" this:"+this);
LOG.info("Ognl: {} this: {}", OgnlRuntime.getPropertyAccessor(Map.class), this);
} catch (OgnlException e) {
// TODO Auto-generated catch block
e.printStackTrace();
LOG.error("Call to shouldCreateIfNew has failed!", e);
}
return isShouldCreateIfNew();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package com.opensymphony.xwork2.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.struts2.StrutsException;

import java.io.File;
Expand All @@ -41,6 +43,8 @@
*/
public class ClassPathFinder {

private static final Logger LOG = LogManager.getLogger(ClassPathFinder.class);

/**
* The String pattern to test against.
*/
Expand Down Expand Up @@ -106,7 +110,7 @@ public Vector<String> findMatches() {
}
}
} catch (IOException e) {
e.printStackTrace();
LOG.warn("Error reading zip file: {}", entry, e);
}
} else {
Vector<String> results = checkEntries(entry.list(), entry, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package com.opensymphony.xwork2.util;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.IOException;
import java.io.LineNumberReader;
import java.io.Reader;
Expand All @@ -40,6 +43,9 @@
* </p>
*/
public class PropertiesReader extends LineNumberReader {

private static final Logger LOG = LogManager.getLogger(PropertiesReader.class);

/**
* Stores the comment lines for the currently processed property.
*/
Expand Down Expand Up @@ -451,7 +457,7 @@ public static String unescapeJava(String str) {
return writer.toString();
} catch (IOException ioe) {
// this should never ever happen while writing to a StringWriter
ioe.printStackTrace();
LOG.warn("Call to unescape java string failed!", ioe);
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public String intercept(ActionInvocation inv) throws Exception {
ServletActionContext.getResponse().getWriter()) {
writer.print(stack.findValue(cmd));
} catch (IOException ex) {
ex.printStackTrace();
LOG.warn("Interceptor in: {} mode has failed!", COMMAND_MODE, ex);
}
cont = false;
} else if (BROWSER_MODE.equals(type)) {
Expand Down Expand Up @@ -286,7 +286,7 @@ protected void printContext() {
printContext(writer);
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
LOG.warn("Call to PrettyPrintWriter failed!", ex);
}
}

Expand Down

0 comments on commit 81a3776

Please sign in to comment.