File tree 1 file changed +20
-13
lines changed
1 file changed +20
-13
lines changed Original file line number Diff line number Diff line change @@ -959,22 +959,29 @@ else if (Platform.ARCH.equals("mips64el")) {
959
959
*/
960
960
private static ArrayList <String > getLinuxLdPaths () {
961
961
ArrayList <String > ldPaths = new ArrayList <String >();
962
+ BufferedReader reader = null ;
962
963
try {
963
- Process process = Runtime .getRuntime ().exec ("/sbin/ldconfig -p" );
964
- BufferedReader reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
965
- String buffer = "" ;
966
- while ((buffer = reader .readLine ()) != null ) {
967
- int startPath = buffer .indexOf (" => " );
968
- int endPath = buffer .lastIndexOf ('/' );
969
- if (startPath != -1 && endPath != -1 && startPath < endPath ) {
970
- String path = buffer .substring (startPath +4 , endPath );
971
- if (ldPaths .contains (path ) == false ) {
972
- ldPaths .add (path );
973
- }
974
- }
964
+ Process process = Runtime .getRuntime ().exec ("/sbin/ldconfig -p" );
965
+ reader = new BufferedReader (new InputStreamReader (process .getInputStream ()));
966
+ String buffer ;
967
+ while ((buffer = reader .readLine ()) != null ) {
968
+ int startPath = buffer .indexOf (" => " );
969
+ int endPath = buffer .lastIndexOf ('/' );
970
+ if (startPath != -1 && endPath != -1 && startPath < endPath ) {
971
+ String path = buffer .substring (startPath + 4 , endPath );
972
+ if (!ldPaths .contains (path )) {
973
+ ldPaths .add (path );
974
+ }
975
975
}
976
- reader . close ();
976
+ }
977
977
} catch (Exception e ) {
978
+ } finally {
979
+ if (reader != null ) {
980
+ try {
981
+ reader .close ();
982
+ } catch (IOException e ) {
983
+ }
984
+ }
978
985
}
979
986
return ldPaths ;
980
987
}
You can’t perform that action at this time.
0 commit comments