Repository: karaf Updated Branches: refs/heads/master d419d9992 -> bc7aa1dcf
[KARAF-3693]only update the instances.properties when the read operation detect instance pid changes (cherry picked from commit 6aa141a74029d60495d166b6c1c0c804909b9caa) (cherry picked from commit 9899e43a117c95d79cec605f5358ee3e22f6b63a) Project: http://git-wip-us.apache.org/repos/asf/karaf/repo Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/bc7aa1dc Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/bc7aa1dc Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/bc7aa1dc Branch: refs/heads/master Commit: bc7aa1dcfd33ccd489e96a75920695f32a62caac Parents: d419d99 Author: Freeman Fang <[email protected]> Authored: Thu Apr 23 17:53:10 2015 +0800 Committer: Freeman Fang <[email protected]> Committed: Thu Apr 23 17:58:03 2015 +0800 ---------------------------------------------------------------------- .../core/internal/InstanceServiceImpl.java | 26 ++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/karaf/blob/bc7aa1dc/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java ---------------------------------------------------------------------- diff --git a/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java b/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java index 027d7f6..6831c55 100644 --- a/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java +++ b/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java @@ -948,6 +948,7 @@ public class InstanceServiceImpl implements InstanceService { } int getInstancePid(final String name) { + boolean updateInstanceProperties = isInstancePidNeedUpdate(name); return execute(new Task<Integer>() { public Integer call(State state) throws IOException { InstanceState instance = state.instances.get(name); @@ -957,7 +958,7 @@ public class InstanceServiceImpl implements InstanceService { checkPid(instance); return instance.pid; } - }, false); + }, updateInstanceProperties); } String getInstanceJavaOpts(final String name) { @@ -986,6 +987,7 @@ public class InstanceServiceImpl implements InstanceService { } String getInstanceState(final String name) { + boolean updateInstanceProperties = isInstancePidNeedUpdate(name); return execute(new Task<String>() { public String call(State state) throws IOException { InstanceState instance = state.instances.get(name); @@ -1014,7 +1016,7 @@ public class InstanceServiceImpl implements InstanceService { return Instance.STARTING; } } - }, true); + }, updateInstanceProperties); } private boolean deleteFile(File fileToDelete) { @@ -1356,6 +1358,26 @@ public class InstanceServiceImpl implements InstanceService { } }, true); } + + private Boolean isInstancePidNeedUpdate(final String name) { + return execute(new Task<Boolean>() { + public Boolean call(State state) throws IOException { + InstanceState instance = state.instances.get(name); + if (instance == null) { + throw new IllegalArgumentException("Instance " + name + " not found"); + } + int origialPid = instance.pid; + checkPid(instance); + int newPid = instance.pid; + if (origialPid == newPid) { + return false; + } else { + return true; + } + + } + }, false); + } private static class ProfileApplier {
