Skip to content

Commit 8565d45

Browse files
committed
HBX-3176: Replace String concatenation while building command in DocExporter
Signed-off-by: Koen Aers <[email protected]>
1 parent d96885d commit 8565d45

File tree

1 file changed

+22
-13
lines changed

1 file changed

+22
-13
lines changed

main/src/main/java/org/hibernate/tool/hbm2x/DocExporter.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,27 @@ private void dotToFile(String dotExeFileName, String dotFileName, String outFile
226226
// d:\graphviz-1.12\bin\dot.exe -Tgif c:\temp\ManualDraw.dot > c:\temp\ManualDraw.gif
227227
// so we follow that model here and read stdout until EOF
228228
//
229-
230-
final String exeCmd =
231-
escape(dotExeFileName) +
232-
" -T" + getFormatForFile(outFileName) + " " +
233-
escape(dotFileName) +
234-
" -o " +
235-
escape(outFileName);
236-
237-
Process p = Runtime.getRuntime().exec(exeCmd);
238-
//p.getErrorStream().
229+
230+
final String[] cmdAsArray = new String[] {
231+
escape( dotExeFileName ),
232+
"-T",
233+
getFormatForFile( outFileName ),
234+
escape( dotFileName ),
235+
"-o",
236+
escape( outFileName )
237+
};
238+
239+
StringBuilder sb = new StringBuilder();
240+
for (String s : cmdAsArray) {
241+
sb.append( s ).append( " " );
242+
}
243+
244+
final String cmdAsString = sb.toString();
245+
246+
Process p = Runtime.getRuntime().exec(cmdAsArray);
247+
239248
try {
240-
log.debug( "Executing: " + exeCmd );
249+
log.debug( "Executing: " + cmdAsString );
241250
// Get the input stream and read from it
242251
InputStream in = p.getErrorStream();
243252
int c;
@@ -248,10 +257,10 @@ private void dotToFile(String dotExeFileName, String dotFileName, String outFile
248257
int i = p.waitFor( );
249258
if(i!=0) {
250259
//TODO: dump system.err
251-
log.error("Error " + i + " while executing: " + exeCmd);
260+
log.error("Error " + i + " while executing: " + cmdAsString);
252261
}
253262
} catch(Exception ie){
254-
log.error( "Error while executing: " + exeCmd, ie );
263+
log.error( "Error while executing: " + cmdAsString, ie );
255264
}
256265
}
257266

0 commit comments

Comments
 (0)