8327370: (ch) sun.nio.ch.Poller.register throws AssertionError

Co-authored-by: Alan Bateman <alanb@openjdk.org>
Reviewed-by: alanb, jpai, djelinski
This commit is contained in:
Daniel Fuchs 2024-06-21 09:43:49 +00:00
parent ed149062d0
commit d2bebffb1f

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -190,7 +190,12 @@ abstract class Poller {
private void register(int fdVal) throws IOException { private void register(int fdVal) throws IOException {
Thread previous = map.put(fdVal, Thread.currentThread()); Thread previous = map.put(fdVal, Thread.currentThread());
assert previous == null; assert previous == null;
implRegister(fdVal); try {
implRegister(fdVal);
} catch (Throwable t) {
map.remove(fdVal);
throw t;
}
} }
/** /**