From d2bebffb1fd26fae4526afd33a818ee776b7102e Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Fri, 21 Jun 2024 09:43:49 +0000 Subject: [PATCH] 8327370: (ch) sun.nio.ch.Poller.register throws AssertionError Co-authored-by: Alan Bateman Reviewed-by: alanb, jpai, djelinski --- src/java.base/share/classes/sun/nio/ch/Poller.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/sun/nio/ch/Poller.java b/src/java.base/share/classes/sun/nio/ch/Poller.java index a24b0cf924a..9d3a0e7d32c 100644 --- a/src/java.base/share/classes/sun/nio/ch/Poller.java +++ b/src/java.base/share/classes/sun/nio/ch/Poller.java @@ -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. * * 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 { Thread previous = map.put(fdVal, Thread.currentThread()); assert previous == null; - implRegister(fdVal); + try { + implRegister(fdVal); + } catch (Throwable t) { + map.remove(fdVal); + throw t; + } } /**