Closed vavishal closed 1 year ago
I have tried to create the private variable as follows in SOAPFaultBuilder.java
private static final boolean captureExceptionMessage = getBooleanSystemProperty();
private static boolean getBooleanSystemProperty() { final String propertyString = System.getProperty("com.sun.xml.ws.fault.SOAPFaultBuilder.captureExceptionMessage"); if (propertyString == null) { //default value return true; } else { return Boolean.getBoolean(propertyString); } }
But the above change is causing the testcase at SOAPFaultBuilderTest.java to fail always since while executing the ExceptionBeanTest.java it calls the SOAPFaultBuilder which initialized the property captureExceptionMessage with default value and also its value is not getting changed in SOAPFaultBuilderTest.java as captureExceptionMessage is a static variable
would non-final field with package private/public access or having public getter/setter for the field to toggle the value help the test?
The following piece of code and then calling SOAPFaultBuilder.setCaptureExceptionMessage(); from the testcase helped
private static boolean captureExceptionMessage = getBooleanSystemProperty();
private static boolean getBooleanSystemProperty() { final String propertyString = System.getProperty("com.sun.xml.ws.fault.SOAPFaultBuilder.captureExceptionMessage"); if (propertyString == null) { default value return true; } else { return Boolean.getBoolean(propertyString); } } public static boolean getCaptureExceptionMessage() { return captureExceptionMessage; } public static void setCaptureExceptionMessage() { captureExceptionMessage = getBooleanSystemProperty(); }
Gentle reminder to review this change
The faultstring in the SOAPFault contains the exception message if any which is the default current behavior
The customer has a requirement where they do not want any exception messages to be displayed in the faultstring for security concerns of exposing class
Therefore, we are adding a new system property -Dcom.sun.xml.ws.fault.doNotPrintExpMsg=true to implement the behavior requested by the customer
Added testcase at ./jaxws-ri/runtime/rt/src/test/java/com/sun/xml/ws/fault/SOAPFaultBuilderTest.java