coverity#1399440 Dm: Dubious method used

Change-Id: Ied0a5218b4f95a300d09483315d577b5bdf01bae
Reviewed-on: https://gerrit.libreoffice.org/43135
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2017-10-04 13:04:25 +01:00
parent e1261e6ea6
commit a25868231a
10 changed files with 52 additions and 15 deletions

View File

@@ -23,6 +23,7 @@ import static org.junit.Assert.fail;
import helper.OfficeProvider; import helper.OfficeProvider;
import helper.ProcessHandler; import helper.ProcessHandler;
import java.io.UnsupportedEncodingException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import lib.TestParameters; import lib.TestParameters;
@@ -110,14 +111,18 @@ public class CheckAPI {
handler.kill(); handler.kill();
util.utils.pause(10000); util.utils.pause(10000);
OfficeProvider op = new OfficeProvider(); OfficeProvider op = new OfficeProvider();
try {
xMSF = (XMultiServiceFactory)op.getManager(param); xMSF = (XMultiServiceFactory)op.getManager(param);
param.put("ServiceFactory",xMSF); param.put("ServiceFactory",xMSF);
try {
oObj = xMSF.createInstance("org.openoffice.RunnerService"); oObj = xMSF.createInstance("org.openoffice.RunnerService");
} }
catch(com.sun.star.uno.Exception e) { catch(com.sun.star.uno.Exception e) {
fail("Could not create Instance of 'org.openoffice.RunnerService'"); fail("Could not create Instance of 'org.openoffice.RunnerService'");
} }
catch (UnsupportedEncodingException e) {
fail("Could not get Manager'");
}
} }
System.out.println(erg); System.out.println(erg);
String processedErg = parseResult(erg); String processedErg = parseResult(erg);

View File

@@ -29,6 +29,7 @@ import share.LogWriter;
import stats.Summarizer; import stats.Summarizer;
import lib.TestParameters; import lib.TestParameters;
import util.PropertyName; import util.PropertyName;
import java.io.UnsupportedEncodingException;
/** /**
* Test base for executing a java complex test. * Test base for executing a java complex test.
@@ -110,6 +111,10 @@ public class java_complex implements TestBase
{ {
office = null; office = null;
} }
catch (UnsupportedEncodingException e)
{
office = null;
}
} }
log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE)); log.initialize(entries[i], param.getBool(PropertyName.LOGGING_IS_ACTIVE));
entries[i].Logger = log; entries[i].Logger = log;

View File

@@ -24,6 +24,7 @@ import java.io.BufferedReader;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import lib.MultiMethodTest; import lib.MultiMethodTest;
import lib.TestCase; import lib.TestCase;
@@ -446,7 +447,7 @@ public class java_fat implements TestBase {
return ifc.run(entry, tEnv, param); return ifc.run(entry, tEnv, param);
} }
private AppProvider startOffice(lib.TestParameters param) { private AppProvider startOffice(lib.TestParameters param) throws UnsupportedEncodingException {
if (m_aDynamicClassLoader == null) { if (m_aDynamicClassLoader == null) {
m_aDynamicClassLoader = new DynamicClassLoader(); m_aDynamicClassLoader = new DynamicClassLoader();
} }

View File

@@ -18,6 +18,8 @@
package helper; package helper;
import java.io.UnsupportedEncodingException;
/** /**
* *
* Interface to get a Manager to access the application to check * Interface to get a Manager to access the application to check
@@ -27,7 +29,7 @@ public interface AppProvider {
/** /**
* Method to get the desired Manager * Method to get the desired Manager
*/ */
Object getManager(lib.TestParameters param); Object getManager(lib.TestParameters param) throws UnsupportedEncodingException;
/** /**
* Method to dispose the desired Manager * Method to dispose the desired Manager

View File

@@ -31,6 +31,7 @@ import com.sun.star.util.XStringSubstitution;
import java.io.File; import java.io.File;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import lib.TestParameters; import lib.TestParameters;
@@ -146,7 +147,7 @@ public class OfficeProvider implements AppProvider
/** /**
* Method to get the ServiceManager of an Office * Method to get the ServiceManager of an Office
*/ */
public Object getManager(lib.TestParameters param) public Object getManager(lib.TestParameters param) throws UnsupportedEncodingException
{ {
String errorMessage = null; String errorMessage = null;
boolean bAppExecutionHasWarning = false; boolean bAppExecutionHasWarning = false;

View File

@@ -19,6 +19,8 @@ package helper;
import java.io.InputStream; import java.io.InputStream;
import java.io.File; import java.io.File;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.LineNumberReader; import java.io.LineNumberReader;
@@ -128,7 +130,7 @@ public class ProcessHandler
* log stream where debug info and output * log stream where debug info and output
* of external command is printed out. * of external command is printed out.
*/ */
public ProcessHandler(String cmdLine, PrintWriter log) public ProcessHandler(String cmdLine, PrintWriter log) throws UnsupportedEncodingException
{ {
this(cmdLine, log, null, null); this(cmdLine, log, null, null);
} }
@@ -157,7 +159,7 @@ public class ProcessHandler
* Waits for the process to end regulary * Waits for the process to end regulary
* *
*/ */
private ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars) private ProcessHandler(String cmdLine, PrintWriter log, File workDir, String[] envVars) throws UnsupportedEncodingException
{ {
this.cmdLine = cmdLine; this.cmdLine = cmdLine;
this.workDir = workDir; this.workDir = workDir;
@@ -165,7 +167,7 @@ public class ProcessHandler
this.envVars = envVars; this.envVars = envVars;
if (log == null) if (log == null)
{ {
this.log = new PrintWriter(System.out); this.log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
} }
else else
{ {

View File

@@ -29,6 +29,8 @@ import com.sun.star.beans.PropertyValue;
import com.sun.star.lang.XTypeProvider; import com.sun.star.lang.XTypeProvider;
import com.sun.star.lang.XServiceInfo; import com.sun.star.lang.XServiceInfo;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
/** /**
@@ -125,8 +127,8 @@ public class dbg {
* @param name The name of the property. * @param name The name of the property.
* @see com.sun.star.beans.XPropertySet * @see com.sun.star.beans.XPropertySet
*/ */
public static void printPropertyInfo(XPropertySet PS, String name) { public static void printPropertyInfo(XPropertySet PS, String name) throws UnsupportedEncodingException {
printPropertyInfo(PS, name, new PrintWriter(System.out)) ; printPropertyInfo(PS, name, new PrintWriter(new OutputStreamWriter(System.out, "UTF-8")));
} }
/** /**

View File

@@ -23,6 +23,7 @@ import util.dbg;
import com.sun.star.form.TabulatorCycle; import com.sun.star.form.TabulatorCycle;
import com.sun.star.uno.Enum; import com.sun.star.uno.Enum;
import java.io.UnsupportedEncodingException;
/** /**
* Testing <code>com.sun.star.form.component.DatabaseForm</code> * Testing <code>com.sun.star.form.component.DatabaseForm</code>
@@ -45,7 +46,7 @@ public class _DatabaseForm extends MultiPropertyTest {
* In this property test only debugging information output * In this property test only debugging information output
* is customized. * is customized.
*/ */
public void _NavigationBarMode() { public void _NavigationBarMode() throws UnsupportedEncodingException {
dbg.printPropertyInfo(oObj, "NavigationBarMode"); dbg.printPropertyInfo(oObj, "NavigationBarMode");
testProperty("NavigationBarMode", new PropertyTester() { testProperty("NavigationBarMode", new PropertyTester() {
@Override @Override
@@ -64,7 +65,7 @@ public class _DatabaseForm extends MultiPropertyTest {
* This property new value is always fixed and debugging * This property new value is always fixed and debugging
* information output is customized. * information output is customized.
*/ */
public void _Cycle() { public void _Cycle() throws UnsupportedEncodingException {
dbg.printPropertyInfo(oObj, "Cycle"); dbg.printPropertyInfo(oObj, "Cycle");
testProperty("Cycle", new PropertyTester() { testProperty("Cycle", new PropertyTester() {
@Override @Override

View File

@@ -20,7 +20,9 @@ package mod._dbaccess;
import ifc.sdb._XCompletedExecution; import ifc.sdb._XCompletedExecution;
import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import lib.StatusException; import lib.StatusException;
import lib.TestCase; import lib.TestCase;
@@ -535,8 +537,13 @@ public class ORowSet extends TestCase {
* @see ifc.sdb._XCompletedExecution * @see ifc.sdb._XCompletedExecution
*/ */
private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler { private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler {
private boolean handlerWasUsed = false; private boolean handlerWasUsed = false;
private PrintWriter log = new PrintWriter(System.out); private PrintWriter log;
InteractionHandlerImpl() throws UnsupportedEncodingException {
log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
}
public boolean checkInteractionHandler() { public boolean checkInteractionHandler() {
return handlerWasUsed; return handlerWasUsed;

View File

@@ -20,7 +20,9 @@ package mod._forms;
import ifc.form._XDatabaseParameterBroadcaster; import ifc.form._XDatabaseParameterBroadcaster;
import ifc.sdb._XCompletedExecution; import ifc.sdb._XCompletedExecution;
import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList; import java.util.ArrayList;
import lib.StatusException; import lib.StatusException;
import lib.TestCase; import lib.TestCase;
@@ -756,7 +758,12 @@ public class ODatabaseForm extends TestCase {
*/ */
private static class ParameterListenerImpl implements _XDatabaseParameterBroadcaster.CheckParameterListener { private static class ParameterListenerImpl implements _XDatabaseParameterBroadcaster.CheckParameterListener {
private boolean listenerWasCalled = false; private boolean listenerWasCalled = false;
private PrintWriter log = new PrintWriter(System.out);
private PrintWriter log;
ParameterListenerImpl() throws UnsupportedEncodingException {
log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
}
/** /**
* Return true, if the listener was called, false otherwise. * Return true, if the listener was called, false otherwise.
@@ -818,7 +825,11 @@ public class ODatabaseForm extends TestCase {
*/ */
private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler { private static class InteractionHandlerImpl implements _XCompletedExecution.CheckInteractionHandler {
private boolean handlerWasUsed = false; private boolean handlerWasUsed = false;
private PrintWriter log = new PrintWriter(System.out); private PrintWriter log;
InteractionHandlerImpl() throws UnsupportedEncodingException {
log = new PrintWriter(new OutputStreamWriter(System.out, "UTF-8"));
}
public boolean checkInteractionHandler() { public boolean checkInteractionHandler() {
return handlerWasUsed; return handlerWasUsed;