mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8282686: Add constructors taking a cause to SocketException
Reviewed-by: alanb, xuelei, lancea, dfuchs
This commit is contained in:
parent
7194097bca
commit
1faa5c8092
7 changed files with 90 additions and 25 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2022, 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
|
||||
|
@ -1353,9 +1353,7 @@ public class DatagramSocket implements java.io.Closeable {
|
|||
Throwable cause = e.getCause();
|
||||
if (cause instanceof SocketException)
|
||||
return (SocketException) cause;
|
||||
SocketException se = new SocketException(e.getMessage());
|
||||
se.initCause(e);
|
||||
return se;
|
||||
return new SocketException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2022, 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
|
||||
|
@ -52,4 +52,27 @@ public class SocketException extends IOException {
|
|||
*/
|
||||
public SocketException() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SocketException} with the
|
||||
* specified detail message and cause.
|
||||
*
|
||||
* @param msg the detail message.
|
||||
* @param cause the cause
|
||||
* @since 19
|
||||
*/
|
||||
public SocketException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@code SocketException} with the
|
||||
* specified cause.
|
||||
*
|
||||
* @param cause the cause
|
||||
* @since 19
|
||||
*/
|
||||
public SocketException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue