Merge pull request #1043 from apache/fix/WW-5458-stack-trace

WW-5458 Replaces e.printStackTrace() with proper logger
This commit is contained in:
Lukasz Lenart
2024-09-10 18:40:56 +02:00
committed by GitHub
4 changed files with 20 additions and 7 deletions
@@ -21,6 +21,8 @@ package com.opensymphony.xwork2.mock;
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;
@@ -31,6 +33,8 @@ import java.util.Map;
*/
public class MockObjectTypeDeterminer implements ObjectTypeDeterminer {
private static final Logger LOG = LogManager.getLogger(MockObjectTypeDeterminer.class);
private Class keyClass;
private Class elementClass;
private String keyProperty;
@@ -69,10 +73,9 @@ public class MockObjectTypeDeterminer implements ObjectTypeDeterminer {
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();
}
@@ -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;
@@ -41,6 +43,8 @@ import java.util.zip.ZipInputStream;
*/
public class ClassPathFinder {
private static final Logger LOG = LogManager.getLogger(ClassPathFinder.class);
/**
* The String pattern to test against.
*/
@@ -106,7 +110,7 @@ public class ClassPathFinder {
}
}
} catch (IOException e) {
e.printStackTrace();
LOG.warn("Error reading zip file: {}", entry, e);
}
} else {
Vector<String> results = checkEntries(entry.list(), entry, "");
@@ -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;
@@ -40,6 +43,9 @@ import java.util.List;
* </p>
*/
public class PropertiesReader extends LineNumberReader {
private static final Logger LOG = LogManager.getLogger(PropertiesReader.class);
/**
* Stores the comment lines for the currently processed property.
*/
@@ -451,7 +457,7 @@ public class PropertiesReader extends LineNumberReader {
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;
}
}
@@ -203,7 +203,7 @@ public class DebuggingInterceptor extends AbstractInterceptor {
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)) {
@@ -286,7 +286,7 @@ public class DebuggingInterceptor extends AbstractInterceptor {
printContext(writer);
writer.close();
} catch (IOException ex) {
ex.printStackTrace();
LOG.warn("Call to PrettyPrintWriter failed!", ex);
}
}