summaryrefslogtreecommitdiff
path: root/odk
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-10-15 12:04:03 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-10-15 14:26:05 +0100
commitab22d11279db912f1b69a48b0fa676972b189aea (patch)
tree40f87ceb93aea8a45e22dd1eda5e9e1c21e6fcbc /odk
parentaa8f218079e2d311927d8aaf64b03b234453fb11 (diff)
coverity#1326731 Dm: Dubious method used
and coverity#1326732 Dm: Dubious method used coverity#1326734 Dm: Dubious method used coverity#1326735 Dm: Dubious method used coverity#1326739 Dm: Dubious method used Change-Id: Id9d39decf7442b503079ebcfe8c881f0f2fe3eb3
Diffstat (limited to 'odk')
-rw-r--r--odk/source/com/sun/star/lib/loader/InstallationFinder.java70
1 files changed, 40 insertions, 30 deletions
diff --git a/odk/source/com/sun/star/lib/loader/InstallationFinder.java b/odk/source/com/sun/star/lib/loader/InstallationFinder.java
index d1f8738cbef9..b04b6f819c45 100644
--- a/odk/source/com/sun/star/lib/loader/InstallationFinder.java
+++ b/odk/source/com/sun/star/lib/loader/InstallationFinder.java
@@ -310,45 +310,53 @@ final class InstallationFinder {
StreamGobbler gobbler = new StreamGobbler( proc.getErrorStream() );
gobbler.start();
- // read the which output from standard input stream
- BufferedReader br = new BufferedReader(
- new InputStreamReader( proc.getInputStream() ) );
- String line = null;
try {
- while ( ( line = br.readLine() ) != null ) {
- if ( path == null ) {
- // get the path from the which output
- int index = line.lastIndexOf( SOFFICE );
- if ( index != -1 ) {
- int end = index + SOFFICE.length();
- for ( int i = 0; i <= index; i++ ) {
- File file = new File( line.substring( i, end ) );
- try {
- if ( file.exists() ) {
- // resolve symlink
- path = file.getCanonicalFile().getParent();
- if ( path != null )
- break;
+ // read the which output from standard input stream
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader( proc.getInputStream(), "UTF-8" ) );
+ String line = null;
+ try {
+ while ( ( line = br.readLine() ) != null ) {
+ if ( path == null ) {
+ // get the path from the which output
+ int index = line.lastIndexOf( SOFFICE );
+ if ( index != -1 ) {
+ int end = index + SOFFICE.length();
+ for ( int i = 0; i <= index; i++ ) {
+ File file = new File( line.substring( i, end ) );
+ try {
+ if ( file.exists() ) {
+ // resolve symlink
+ path = file.getCanonicalFile().getParent();
+ if ( path != null )
+ break;
+ }
+ } catch ( SecurityException e ) {
+ return null;
}
- } catch ( SecurityException e ) {
- return null;
}
}
}
}
+ } catch ( IOException e ) {
+ // if an I/O exception is thrown, return <code>null</null>
+ System.err.println( "com.sun.star.lib.loader." +
+ "InstallationFinder::getPathFromWhich: " +
+ "reading which command output failed: " + e );
+ return null;
+ } finally {
+ try {
+ br.close();
+ } catch ( IOException e ) {
+ // closing standard input stream failed, ignore
+ }
}
- } catch ( IOException e ) {
- // if an I/O exception is thrown, return <code>null</null>
+ } catch ( UnsupportedEncodingException e ) {
+ // if an Encoding exception is thrown, return <code>null</null>
System.err.println( "com.sun.star.lib.loader." +
"InstallationFinder::getPathFromWhich: " +
- "reading which command output failed: " + e );
+ "encoding failed: " + e );
return null;
- } finally {
- try {
- br.close();
- } catch ( IOException e ) {
- // closing standard input stream failed, ignore
- }
}
try {
@@ -563,12 +571,14 @@ final class InstallationFinder {
public void run() {
try {
BufferedReader br = new BufferedReader(
- new InputStreamReader( m_istream ) );
+ new InputStreamReader( m_istream, "UTF-8" ) );
// read from input stream
while ( br.readLine() != null ) {
// don't handle line content
}
br.close();
+ } catch (UnsupportedEncodingException e) {
+ // cannot read from input stream
} catch ( IOException e ) {
// stop reading from input stream
}