diff --git a/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java b/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java index cc896425c86fa81a507cb1a9117acc65f9ad644c..352ab7ebd4d3172aa5edebfa6bd65b8a38a1c47c 100644 --- a/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java +++ b/src/macosx/classes/sun/nio/ch/KQueueSelectorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2015, 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 @@ -84,10 +84,24 @@ class KQueueSelectorImpl long fds = IOUtil.makePipe(false); fd0 = (int)(fds >>> 32); fd1 = (int)fds; - kqueueWrapper = new KQueueArrayWrapper(); - kqueueWrapper.initInterrupt(fd0, fd1); - fdMap = new HashMap<>(); - totalChannels = 1; + try { + kqueueWrapper = new KQueueArrayWrapper(); + kqueueWrapper.initInterrupt(fd0, fd1); + fdMap = new HashMap<>(); + totalChannels = 1; + } catch (Throwable t) { + try { + FileDispatcherImpl.closeIntFD(fd0); + } catch (IOException ioe0) { + t.addSuppressed(ioe0); + } + try { + FileDispatcherImpl.closeIntFD(fd1); + } catch (IOException ioe1) { + t.addSuppressed(ioe1); + } + throw t; + } } diff --git a/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java b/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java index 81ae3f6be4bfed74dbc5bda1467d597d6fe8ca56..81db74f09e35986523d6395d2ab1ec70bf96b2c6 100644 --- a/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java +++ b/src/solaris/classes/sun/nio/ch/DevPollSelectorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2015, 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 @@ -68,9 +68,23 @@ class DevPollSelectorImpl long pipeFds = IOUtil.makePipe(false); fd0 = (int) (pipeFds >>> 32); fd1 = (int) pipeFds; - pollWrapper = new DevPollArrayWrapper(); - pollWrapper.initInterrupt(fd0, fd1); - fdToKey = new HashMap(); + try { + pollWrapper = new DevPollArrayWrapper(); + pollWrapper.initInterrupt(fd0, fd1); + fdToKey = new HashMap<>(); + } catch (Throwable t) { + try { + FileDispatcherImpl.closeIntFD(fd0); + } catch (IOException ioe0) { + t.addSuppressed(ioe0); + } + try { + FileDispatcherImpl.closeIntFD(fd1); + } catch (IOException ioe1) { + t.addSuppressed(ioe1); + } + throw t; + } } protected int doSelect(long timeout) diff --git a/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java b/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java index d5f24e80252f346d4c91c5ce504310eda0d2ef22..1528b9e16b8182864bf113235f336f6882243096 100644 --- a/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java +++ b/src/solaris/classes/sun/nio/ch/EPollSelectorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, 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 @@ -65,9 +65,23 @@ class EPollSelectorImpl long pipeFds = IOUtil.makePipe(false); fd0 = (int) (pipeFds >>> 32); fd1 = (int) pipeFds; - pollWrapper = new EPollArrayWrapper(); - pollWrapper.initInterrupt(fd0, fd1); - fdToKey = new HashMap<>(); + try { + pollWrapper = new EPollArrayWrapper(); + pollWrapper.initInterrupt(fd0, fd1); + fdToKey = new HashMap<>(); + } catch (Throwable t) { + try { + FileDispatcherImpl.closeIntFD(fd0); + } catch (IOException ioe0) { + t.addSuppressed(ioe0); + } + try { + FileDispatcherImpl.closeIntFD(fd1); + } catch (IOException ioe1) { + t.addSuppressed(ioe1); + } + throw t; + } } protected int doSelect(long timeout) throws IOException { diff --git a/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java b/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java index 17c9f03ec5da9572918388a9edeb87da3e7c2a37..1911c3507c0d87164a6871e5fde39db86ad7f8b2 100644 --- a/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java +++ b/src/solaris/classes/sun/nio/ch/PollSelectorImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2015, 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 @@ -57,9 +57,23 @@ class PollSelectorImpl long pipeFds = IOUtil.makePipe(false); fd0 = (int) (pipeFds >>> 32); fd1 = (int) pipeFds; - pollWrapper = new PollArrayWrapper(INIT_CAP); - pollWrapper.initInterrupt(fd0, fd1); - channelArray = new SelectionKeyImpl[INIT_CAP]; + try { + pollWrapper = new PollArrayWrapper(INIT_CAP); + pollWrapper.initInterrupt(fd0, fd1); + channelArray = new SelectionKeyImpl[INIT_CAP]; + } catch (Throwable t) { + try { + FileDispatcherImpl.closeIntFD(fd0); + } catch (IOException ioe0) { + t.addSuppressed(ioe0); + } + try { + FileDispatcherImpl.closeIntFD(fd1); + } catch (IOException ioe1) { + t.addSuppressed(ioe1); + } + throw t; + } } protected int doSelect(long timeout)