Skip to content

Commit 7dbd479

Browse files
committed
load scripts only once
1 parent f28bad4 commit 7dbd479

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

operator/src/main/java/oracle/kubernetes/operator/helpers/ConfigMapHelper.java

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,18 @@ protected V1ConfigMap computeDomainConfigMap() {
152152
metadata.setLabels(labels);
153153

154154
cm.setMetadata(metadata);
155+
LOGGER.warning("xyz- computeDomainConfigMap called, cm.getData() is " + cm.getData());
155156
cm.setData(loadScripts());
157+
LOGGER.warning("xyz- computeDomainConfigMap called, cm.getData() after setData().size() is " + cm.getData().size());
156158

157159
return cm;
158160
}
159-
161+
Map<String, String> scripts;
160162
private synchronized Map<String, String> loadScripts() {
163+
if (scripts != null) {
164+
LOGGER.warning("xyz- computeDomainConfigMap loadScripts() returning previously loaded scripts");
165+
return scripts;
166+
}
161167
URI uri = null;
162168
try {
163169
uri = getClass().getResource(SCRIPT_LOCATION).toURI();
@@ -169,18 +175,19 @@ private synchronized Map<String, String> loadScripts() {
169175
try {
170176
if ("jar".equals(uri.getScheme())) {
171177
try (FileSystem fileSystem = FileSystems.newFileSystem(uri, Collections.<String, Object>emptyMap())) {
172-
return walkScriptsPath(fileSystem.getPath(SCRIPTS));
178+
return scripts = walkScriptsPath(fileSystem.getPath(SCRIPTS));
173179
}
174180
} else {
175-
return walkScriptsPath(Paths.get(uri));
176-
}
177-
} catch (FileSystemAlreadyExistsException ale) {
178-
LOGGER.warning(MessageKeys.EXCEPTION, new IOException("xyz-FileSystemAlreadyExistsException uri is " + uri));
179-
try (FileSystem fileSystem = FileSystems.getFileSystem(uri)) {
180-
return walkScriptsPath(fileSystem.getPath(SCRIPTS));
181-
} catch(IOException e) {
182-
throw new RuntimeException(e);
181+
return scripts = walkScriptsPath(Paths.get(uri));
183182
}
183+
// } catch (FileSystemAlreadyExistsException ale) {
184+
// LOGGER.warning(MessageKeys.EXCEPTION, new IOException("xyz-FileSystemAlreadyExistsException uri is " + uri));
185+
// try (FileSystem fileSystem = FileSystems.getFileSystem(uri)) {
186+
// LOGGER.warning(MessageKeys.EXCEPTION, new IOException("xyz-FileSystem " + fileSystem + ", isOpen()=" + fileSystem.isOpen()));
187+
// return walkScriptsPath(fileSystem.getPath(SCRIPTS));
188+
// } catch(IOException e) {
189+
// throw new RuntimeException(e);
190+
// }
184191
} catch (IOException e) {
185192
LOGGER.warning(MessageKeys.EXCEPTION, e);
186193
throw new RuntimeException(e);

0 commit comments

Comments
 (0)