@@ -249,21 +249,23 @@ static void initializeOOMENotifier(String onOutOfMemoryVal) throws IOException {
249249 private static void writeScript (
250250 InputStream template , Path scriptPath , String execClass , String crashFile )
251251 throws IOException {
252- try (BufferedReader br = new BufferedReader (new InputStreamReader (template ))) {
253- try (BufferedWriter bw = Files .newBufferedWriter (scriptPath )) {
254- br .lines ()
255- .map (
256- line -> {
257- line = Strings .replace (line , "!AGENT_JAR!" , execClass );
258- if (crashFile != null ) {
259- line = Strings .replace (line , "!JAVA_ERROR_FILE!" , crashFile );
260- }
261- return line ;
262- })
263- .forEach (line -> writeLine (bw , line ));
252+ if (!Files .exists (scriptPath )) {
253+ try (BufferedReader br = new BufferedReader (new InputStreamReader (template ))) {
254+ try (BufferedWriter bw = Files .newBufferedWriter (scriptPath )) {
255+ br .lines ()
256+ .map (
257+ line -> {
258+ line = Strings .replace (line , "!AGENT_JAR!" , execClass );
259+ if (crashFile != null ) {
260+ line = Strings .replace (line , "!JAVA_ERROR_FILE!" , crashFile );
261+ }
262+ return line ;
263+ })
264+ .forEach (line -> writeLine (bw , line ));
265+ }
264266 }
267+ Files .setPosixFilePermissions (scriptPath , PosixFilePermissions .fromString ("r-xr-xr-x" ));
265268 }
266- Files .setPosixFilePermissions (scriptPath , PosixFilePermissions .fromString ("r-xr-xr-x" ));
267269 }
268270
269271 private static void writeLine (BufferedWriter bw , String line ) {
0 commit comments