Small format changes in script and monitor packages

Just three files - just adding {}s to if and for statements or making
them single line.
This commit is contained in:
Nik Everett 2016-04-13 22:00:04 -04:00
parent 0386d8ec84
commit 86a9365c53
3 changed files with 35 additions and 37 deletions

View File

@ -79,29 +79,34 @@ public class DeadlockAnalyzer {
Set<LinkedHashSet<ThreadInfo>> cycles = new HashSet<>();
for (Map.Entry<Long, ThreadInfo> entry : threadInfoMap.entrySet()) {
LinkedHashSet<ThreadInfo> cycle = new LinkedHashSet<>();
for (ThreadInfo t = entry.getValue(); !cycle.contains(t); t = threadInfoMap.get(Long.valueOf(t.getLockOwnerId())))
for (ThreadInfo t = entry.getValue(); !cycle.contains(t); t = threadInfoMap.get(Long.valueOf(t.getLockOwnerId()))) {
cycle.add(t);
}
if (!cycles.contains(cycle))
if (!cycles.contains(cycle)) {
cycles.add(cycle);
}
}
return cycles;
}
private Set<LinkedHashSet<ThreadInfo>> calculateCycleDeadlockChains(Map<Long, ThreadInfo> threadInfoMap, Set<LinkedHashSet<ThreadInfo>> cycles) {
private Set<LinkedHashSet<ThreadInfo>> calculateCycleDeadlockChains(Map<Long, ThreadInfo> threadInfoMap,
Set<LinkedHashSet<ThreadInfo>> cycles) {
ThreadInfo allThreads[] = threadBean.getThreadInfo(threadBean.getAllThreadIds());
Set<LinkedHashSet<ThreadInfo>> deadlockChain = new HashSet<>();
Set<Long> knownDeadlockedThreads = threadInfoMap.keySet();
for (ThreadInfo threadInfo : allThreads) {
Thread.State state = threadInfo.getThreadState();
if (state == Thread.State.BLOCKED && !knownDeadlockedThreads.contains(threadInfo.getThreadId())) {
for (LinkedHashSet cycle : cycles) {
for (LinkedHashSet<ThreadInfo> cycle : cycles) {
if (cycle.contains(threadInfoMap.get(Long.valueOf(threadInfo.getLockOwnerId())))) {
LinkedHashSet<ThreadInfo> chain = new LinkedHashSet<>();
for (ThreadInfo node = threadInfo; !chain.contains(node); node = threadInfoMap.get(Long.valueOf(node.getLockOwnerId())))
ThreadInfo node = threadInfo;
while (!chain.contains(node)) {
chain.add(node);
node = threadInfoMap.get(Long.valueOf(node.getLockOwnerId()));
}
deadlockChain.add(chain);
}
}
@ -135,10 +140,12 @@ public class DeadlockAnalyzer {
for (int x = 0; x < members.length; x++) {
ThreadInfo ti = members[x];
sb.append(ti.getThreadName());
if (x < members.length)
if (x < members.length) {
sb.append(" > ");
if (x == members.length - 1)
}
if (x == members.length - 1) {
sb.append(ti.getLockOwnerName());
}
builder.add(ti.getThreadId());
}
this.description = sb.toString();

View File

@ -46,7 +46,6 @@ public class Script implements ToXContent, Streamable {
* using {@link StreamInput#readOptionalStreamable(Supplier)}
*/
public static final Supplier<Script> SUPPLIER = new Supplier<Script>() {
@Override
public Script get() {
return new Script();
@ -238,30 +237,26 @@ public class Script implements ToXContent, Streamable {
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
Script other = (Script) obj;
if (lang == null) {
if (other.lang != null)
return false;
} else if (!lang.equals(other.lang))
return false;
if (other.lang != null) return false;
} else {
if (!lang.equals(other.lang)) return false;
}
if (params == null) {
if (other.params != null)
return false;
} else if (!params.equals(other.params))
return false;
if (other.params != null) return false;
} else {
if (!params.equals(other.params)) return false;
}
if (script == null) {
if (other.script != null)
return false;
} else if (!script.equals(other.script))
return false;
if (type != other.type)
return false;
if (other.script != null) return false;
} else {
if (!script.equals(other.script)) return false;
}
if (type != other.type) return false;
return true;
}

View File

@ -149,15 +149,11 @@ public class Template extends Script {
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
if (this == obj) return true;
if (!super.equals(obj)) return false;
if (getClass() != obj.getClass()) return false;
Template other = (Template) obj;
if (contentType != other.contentType)
return false;
if (contentType != other.contentType) return false;
return true;
}