8239055: Wrong implementation of VMState.hasListener
Correct the VMState.hasListener implementation to return WeakReference<VMListener> type Reviewed-by: sspitsyn, poonam
This commit is contained in:
parent
3ca275fb91
commit
ea55699f34
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -174,7 +174,14 @@ class VMState {
|
||||
}
|
||||
|
||||
synchronized boolean hasListener(VMListener listener) {
|
||||
return listeners.contains(listener);
|
||||
Iterator<WeakReference<VMListener>> iter = listeners.iterator();
|
||||
while (iter.hasNext()) {
|
||||
WeakReference<VMListener> ref = iter.next();
|
||||
if (listener.equals(ref.get())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
synchronized void removeListener(VMListener listener) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user