7
7
import java .net .URI ;
8
8
import java .net .URISyntaxException ;
9
9
import java .nio .charset .StandardCharsets ;
10
+ import java .nio .file .FileAlreadyExistsException ;
10
11
import java .nio .file .FileSystem ;
11
12
import java .nio .file .FileSystemAlreadyExistsException ;
12
13
import java .nio .file .FileSystems ;
@@ -152,33 +153,30 @@ protected V1ConfigMap computeDomainConfigMap() {
152
153
metadata .setLabels (labels );
153
154
154
155
cm .setMetadata (metadata );
155
- LOGGER .warning ("xyz- computeDomainConfigMap called, cm.getData() is " + cm .getData ());
156
- cm .setData (loadScripts ());
157
- LOGGER .warning ("xyz- computeDomainConfigMap called, cm.getData() after setData().size() is " + cm .getData ().size ());
156
+ LOGGER .warning ("xyz- computeDomainConfigMap called for domainNamespace:" + domainNamespace + " , cm.getData() is " + cm .getData ());
157
+ cm .setData (loadScripts (domainNamespace ));
158
+ LOGGER .warning ("xyz- computeDomainConfigMap called for domainNamespace:" + domainNamespace + " , cm.getData() after setData().size() is " + cm .getData ().size ());
158
159
159
160
return cm ;
160
161
}
161
- Map <String , String > scripts ;
162
- private synchronized Map <String , String > loadScripts () {
163
- if (scripts != null ) {
164
- LOGGER .warning ("xyz- computeDomainConfigMap loadScripts() returning previously loaded scripts" );
165
- return scripts ;
166
- }
162
+
163
+ private static synchronized Map <String , String > loadScripts (String domainNamespace ) {
167
164
URI uri = null ;
168
165
try {
169
- uri = getClass () .getResource (SCRIPT_LOCATION ).toURI ();
166
+ uri = ScriptConfigMapStep . class .getResource (SCRIPT_LOCATION ).toURI ();
170
167
} catch (URISyntaxException e ) {
171
168
LOGGER .warning (MessageKeys .EXCEPTION , e );
172
169
throw new RuntimeException (e );
173
170
}
174
-
171
+ LOGGER . warning ( "xyz- loadScripts() domainNamespace:" + domainNamespace + ", uri is " + uri + ", scheme=" + uri . getScheme ());
175
172
try {
176
173
if ("jar" .equals (uri .getScheme ())) {
177
174
try (FileSystem fileSystem = FileSystems .newFileSystem (uri , Collections .<String , Object >emptyMap ())) {
178
- return scripts = walkScriptsPath (fileSystem .getPath (SCRIPTS ));
175
+ LOGGER .warning ("xyz- walkScriptsPath for domainNamespace=" + domainNamespace + ", fileSystem=" + fileSystem );
176
+ return walkScriptsPath (fileSystem .getPath (SCRIPTS ), domainNamespace );
179
177
}
180
178
} else {
181
- return scripts = walkScriptsPath (Paths .get (uri ));
179
+ return walkScriptsPath (Paths .get (uri ), domainNamespace );
182
180
}
183
181
// } catch (FileSystemAlreadyExistsException ale) {
184
182
// LOGGER.warning(MessageKeys.EXCEPTION, new IOException("xyz-FileSystemAlreadyExistsException uri is " + uri));
@@ -189,12 +187,13 @@ private synchronized Map<String, String> loadScripts() {
189
187
// throw new RuntimeException(e);
190
188
// }
191
189
} catch (IOException e ) {
190
+ LOGGER .warning (MessageKeys .EXCEPTION , new FileAlreadyExistsException ("xyz- uri," + uri ));
192
191
LOGGER .warning (MessageKeys .EXCEPTION , e );
193
192
throw new RuntimeException (e );
194
193
}
195
194
}
196
195
197
- private Map <String , String > walkScriptsPath (Path scriptsDir ) throws IOException {
196
+ private static Map <String , String > walkScriptsPath (Path scriptsDir , String domainNamespace ) throws IOException {
198
197
try (Stream <Path > walk = Files .walk (scriptsDir , 1 )) {
199
198
Map <String , String > data = walk .filter (i -> !Files .isDirectory (i )).collect (Collectors .toMap (
200
199
i -> i .getFileName ().toString (),
@@ -204,7 +203,7 @@ private Map<String, String> walkScriptsPath(Path scriptsDir) throws IOException
204
203
}
205
204
}
206
205
207
- private byte [] read (Path path ) {
206
+ private static byte [] read (Path path ) {
208
207
try {
209
208
return Files .readAllBytes (path );
210
209
} catch (IOException io ) {
0 commit comments