Fixes the compilation on JDK 8.

This commit is contained in:
lubomir.marinov 2014-07-25 06:14:43 +00:00
parent a3caa371aa
commit bc8ab03637
2 changed files with 60 additions and 7 deletions

View File

@ -194,14 +194,40 @@ public class GoogleRelayedCandidateDelegate
try
{
packetToReceive =
new DatagramPacket(data, 0, data.length, peerAddress);
packetToReceive
= new DatagramPacket(data, 0, data.length, peerAddress);
}
catch (SocketException sex)
catch (Throwable t)
{
packetToReceive = null;
/*
* The signature of the DatagramPacket constructor was changed
* in JDK 8 to not declare that it may throw a SocketException.
*/
if (t instanceof SocketException)
{
packetToReceive = null;
}
else if (t instanceof Error)
{
throw (Error) t;
}
else if (t instanceof RuntimeException)
{
throw (RuntimeException) t;
}
else
{
/*
* Unfortunately, we cannot re-throw it. Anyway, it was
* unlikely to occur on JDK 7.
*/
if (t instanceof InterruptedException)
{
Thread.currentThread().interrupt();
}
packetToReceive = null;
}
}
if (packetToReceive != null)
{
synchronized (packetsToReceive)

View File

@ -584,9 +584,36 @@ public class RelayedCandidateDatagramSocket
packetToReceive
= new DatagramPacket(data, 0, data.length, peerAddress);
}
catch (SocketException sex)
catch (Throwable t)
{
packetToReceive = null;
/*
* The signature of the DatagramPacket constructor was changed
* in JDK 8 to not declare that it may throw a SocketException.
*/
if (t instanceof SocketException)
{
packetToReceive = null;
}
else if (t instanceof Error)
{
throw (Error) t;
}
else if (t instanceof RuntimeException)
{
throw (RuntimeException) t;
}
else
{
/*
* Unfortunately, we cannot re-throw it. Anyway, it was
* unlikely to occur on JDK 7.
*/
if (t instanceof InterruptedException)
{
Thread.currentThread().interrupt();
}
packetToReceive = null;
}
}
if (packetToReceive != null)
{