1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 00:59:39 +02:00

Bump ErrorProne to 2.5.1 and refactor Providers a bit

This also resulted in a refactoring of the Providers and parsing
Exceptions. NumberFormatException and ParseException can now be thrown
directly, the wrapping in a SmackParsingException is down at a higher
layer, i.e. in AbstractProvider.
This commit is contained in:
Florian Schmaus 2021-01-28 22:05:47 +01:00
parent 1df0763f92
commit a7b3303f3e
136 changed files with 574 additions and 551 deletions

View file

@ -85,7 +85,7 @@ public final class JingleSession extends JingleNegotiator implements MediaReceiv
private StanzaFilter packetFilter;
protected List<JingleMediaManager> jingleMediaManagers = null;
List<JingleMediaManager> jingleMediaManagers = null;
private JingleSessionState sessionState;
@ -228,7 +228,7 @@ public final class JingleSession extends JingleNegotiator implements MediaReceiv
* @param sessionId TODO javadoc me please
* the sid to set
*/
protected void setSid(String sessionId) {
void setSid(String sessionId) {
sid = sessionId;
}
@ -237,7 +237,7 @@ public final class JingleSession extends JingleNegotiator implements MediaReceiv
*
* @return the generated session ID.
*/
protected static String generateSessionId() {
static String generateSessionId() {
return String.valueOf(randomGenerator.nextInt(Integer.MAX_VALUE) + randomGenerator.nextInt(Integer.MAX_VALUE));
}
@ -675,7 +675,7 @@ public final class JingleSession extends JingleNegotiator implements MediaReceiv
/**
* Remove the stanza listener used for processing packet.
*/
protected void removeAsyncPacketListener() {
void removeAsyncPacketListener() {
if (packetListener != null) {
getConnection().removeAsyncStanzaListener(packetListener);
@ -687,7 +687,7 @@ public final class JingleSession extends JingleNegotiator implements MediaReceiv
* Install the stanza listener. The listener is responsible for responding
* to any stanza that we receive...
*/
protected void updatePacketListener() {
void updatePacketListener() {
removeAsyncPacketListener();
LOGGER.fine("UpdatePacketListener");
@ -895,7 +895,7 @@ public final class JingleSession extends JingleNegotiator implements MediaReceiv
*
* @param reason the reason.
*/
protected void triggerSessionClosed(String reason) {
void triggerSessionClosed(String reason) {
// for (ContentNegotiator contentNegotiator : contentNegotiators) {
//
// contentNegotiator.stopJingleMediaSession();
@ -919,7 +919,7 @@ public final class JingleSession extends JingleNegotiator implements MediaReceiv
*
* @param exc the exception.
*/
protected void triggerSessionClosedOnError(XMPPException exc) {
void triggerSessionClosedOnError(XMPPException exc) {
for (ContentNegotiator contentNegotiator : contentNegotiators) {
contentNegotiator.stopJingleMediaSession();
@ -954,7 +954,7 @@ public final class JingleSession extends JingleNegotiator implements MediaReceiv
*
* @param participant the participant.
*/
protected void triggerMediaReceived(String participant) {
void triggerMediaReceived(String participant) {
List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) {
if (li instanceof JingleSessionListener) {

View file

@ -271,7 +271,7 @@ public class MediaNegotiator extends JingleNegotiator {
* @param jingle TODO javadoc me please
* The input packet
* @return a Jingle packet
* @throws JingleException
* @throws JingleException in case of an jingle exception.
*/
private IQ receiveSessionInfoAction(Jingle jingle, JingleDescription description) throws JingleException {
IQ response = null;
@ -308,10 +308,10 @@ public class MediaNegotiator extends JingleNegotiator {
* A jmf description has been accepted. In this case, we must save the
* accepted payload type and notify any listener...
*
* @param jin TODO javadoc me please
* The input packet
* @param jingle TODO javadoc me please
* @param description the description.
* @return a Jingle packet
* @throws JingleException
* @throws JingleException in case of an jingle exception.
*/
private IQ receiveSessionAcceptAction(Jingle jingle, JingleDescription description) throws JingleException {
IQ response = null;

View file

@ -448,6 +448,7 @@ public class AudioChannel {
failed = true;
}
@SuppressWarnings("LockOnBoxedPrimitive")
private synchronized boolean waitForState(Processor p, int state) {
p.addControllerListener(new StateListener());
failed = false;
@ -485,6 +486,7 @@ public class AudioChannel {
class StateListener implements ControllerListener {
@SuppressWarnings("LockOnBoxedPrimitive")
@Override
public void controllerUpdate(ControllerEvent ce) {

View file

@ -150,6 +150,7 @@ public class ImageTransmitter implements Runnable {
}
catch (Exception e) {
LOGGER.log(Level.WARNING, "exception", e);
}
}

View file

@ -28,7 +28,6 @@ import org.jivesoftware.smackx.jingleold.JingleSession;
import org.jivesoftware.smackx.jingleold.listeners.CreatedJingleSessionListener;
import org.jivesoftware.smackx.jingleold.listeners.JingleSessionListener;
import org.jivesoftware.smackx.jingleold.media.PayloadType;
import org.jivesoftware.smackx.jingleold.nat.ICECandidate.Type;
@SuppressWarnings("UnusedVariable")
public class ICETransportManager extends JingleTransportManager implements JingleSessionListener, CreatedJingleSessionListener {
@ -62,7 +61,7 @@ public class ICETransportManager extends JingleTransportManager implements Jingl
@Override
public void sessionEstablished(PayloadType pt, TransportCandidate rc, TransportCandidate lc, JingleSession jingleSession) throws NotConnectedException, InterruptedException {
if (lc instanceof ICECandidate) {
if (((ICECandidate) lc).getType().equals(Type.relay)) {
if (((ICECandidate) lc).getType().equals(ICECandidate.Type.relay)) {
RTPBridge rtpBridge = RTPBridge.relaySession(lc.getConnection(), lc.getSessionId(), lc.getPassword(), rc, lc);
}
}

View file

@ -161,11 +161,7 @@ public class STUNResolver extends TransportResolver {
// Parse the port
parser.next();
parser.next();
try {
serverPort = Integer.parseInt(parser.nextText());
}
catch (Exception e) {
}
serverPort = Integer.parseInt(parser.nextText());
// If we have a valid hostname and port, add
// it to the list.

View file

@ -37,7 +37,6 @@ import org.jivesoftware.smackx.jingleold.JingleNegotiatorState;
import org.jivesoftware.smackx.jingleold.JingleSession;
import org.jivesoftware.smackx.jingleold.listeners.JingleListener;
import org.jivesoftware.smackx.jingleold.listeners.JingleTransportListener;
import org.jivesoftware.smackx.jingleold.nat.ICECandidate.Type;
import org.jivesoftware.smackx.jingleold.packet.Jingle;
import org.jivesoftware.smackx.jingleold.packet.JingleContent;
import org.jivesoftware.smackx.jingleold.packet.JingleTransport;
@ -364,7 +363,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
for (TransportCandidate candidate : remoteCandidates) {
if (candidate instanceof ICECandidate) {
ICECandidate iceCandidate = (ICECandidate) candidate;
if (iceCandidate.getType().equals(Type.relay)) {
if (iceCandidate.getType().equals(ICECandidate.Type.relay)) {
// TODO Check if the relay is reachable.
addValidRemoteCandidate(iceCandidate);
foundRemoteRelay = true;
@ -379,7 +378,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
for (TransportCandidate candidate : offeredCandidates) {
if (candidate instanceof ICECandidate) {
ICECandidate iceCandidate = (ICECandidate) candidate;
if (iceCandidate.getType().equals(Type.relay)) {
if (iceCandidate.getType().equals(ICECandidate.Type.relay)) {
foundLocalRelay = true;
}
}
@ -512,7 +511,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
/**
* Parse the list of transport candidates from a Jingle packet.
*
* @param jin The input jingle packet
* @param jingle The input jingle packet
*/
private List<TransportCandidate> obtainCandidatesList(Jingle jingle) {
List<TransportCandidate> result = new ArrayList<>();
@ -943,7 +942,7 @@ public abstract class TransportNegotiator extends JingleNegotiator {
result = chose;
}
if (result != null && result.getType().equals(Type.relay))
if (result != null && result.getType().equals(ICECandidate.Type.relay))
LOGGER.fine("Relay Type");
return result;

View file

@ -41,21 +41,15 @@ public abstract class JingleContentDescriptionProvider extends ExtensionElementP
* @return a payload type element
*/
protected JinglePayloadType parsePayload(final XmlPullParser parser) {
int ptId = 0;
int ptId;
String ptName;
int ptChannels = 0;
int ptChannels;
try {
ptId = Integer.parseInt(parser.getAttributeValue("", "id"));
} catch (Exception e) {
}
ptId = Integer.parseInt(parser.getAttributeValue("", "id"));
ptName = parser.getAttributeValue("", "name");
try {
ptChannels = Integer.parseInt(parser.getAttributeValue("", "channels"));
} catch (Exception e) {
}
ptChannels = Integer.parseInt(parser.getAttributeValue("", "channels"));
return new JinglePayloadType(new PayloadType(ptId, ptName, ptChannels));
}
@ -115,12 +109,7 @@ public abstract class JingleContentDescriptionProvider extends ExtensionElementP
public JinglePayloadType parsePayload(final XmlPullParser parser) {
JinglePayloadType pte = super.parsePayload(parser);
PayloadType.Audio pt = new PayloadType.Audio(pte.getPayloadType());
int ptClockRate = 0;
try {
ptClockRate = Integer.parseInt(parser.getAttributeValue("", "clockrate"));
} catch (Exception e) {
}
int ptClockRate = Integer.parseInt(parser.getAttributeValue("", "clockrate"));
pt.setClockRate(ptClockRate);
return new JinglePayloadType.Audio(pt);

View file

@ -41,21 +41,15 @@ public abstract class JingleDescriptionProvider extends ExtensionElementProvider
* @return a payload type element
*/
protected PayloadType parsePayload(final XmlPullParser parser) {
int ptId = 0;
int ptId;
String ptName;
int ptChannels = 0;
int ptChannels;
try {
ptId = Integer.parseInt(parser.getAttributeValue("", "id"));
} catch (Exception e) {
}
ptId = Integer.parseInt(parser.getAttributeValue("", "id"));
ptName = parser.getAttributeValue("", "name");
try {
ptChannels = Integer.parseInt(parser.getAttributeValue("", "channels"));
} catch (Exception e) {
}
ptChannels = Integer.parseInt(parser.getAttributeValue("", "channels"));
return new PayloadType(ptId, ptName, ptChannels);
}
@ -114,12 +108,7 @@ public abstract class JingleDescriptionProvider extends ExtensionElementProvider
public PayloadType parsePayload(final XmlPullParser parser) {
PayloadType pte = super.parsePayload(parser);
PayloadType.Audio pt = new PayloadType.Audio(pte);
int ptClockRate = 0;
try {
ptClockRate = Integer.parseInt(parser.getAttributeValue("", "clockrate"));
} catch (Exception e) {
}
int ptClockRate = Integer.parseInt(parser.getAttributeValue("", "clockrate"));
pt.setClockRate(ptClockRate);
return pt;

View file

@ -132,11 +132,7 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
}
if (generation != null) {
try {
mt.setGeneration(Integer.parseInt(generation));
}
catch (Exception e) {
}
mt.setGeneration(Integer.parseInt(generation));
}
if (ip != null) {
@ -151,11 +147,7 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
}
if (network != null) {
try {
mt.setNetwork(Integer.parseInt(network));
}
catch (Exception e) {
}
mt.setNetwork(Integer.parseInt(network));
}
if (username != null) {
@ -167,19 +159,11 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
}
if (port != null) {
try {
mt.setPort(Integer.parseInt(port));
}
catch (Exception e) {
}
mt.setPort(Integer.parseInt(port));
}
if (preference != null) {
try {
mt.setPreference(Integer.parseInt(preference));
}
catch (Exception e) {
}
mt.setPreference(Integer.parseInt(preference));
}
if (proto != null) {
@ -234,11 +218,7 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
// LOGGER.debug();
if (generation != null) {
try {
mt.setGeneration(Integer.parseInt(generation));
}
catch (Exception e) {
}
mt.setGeneration(Integer.parseInt(generation));
}
if (ip != null) {
@ -250,11 +230,7 @@ public abstract class JingleTransportProvider extends ExtensionElementProvider<J
}
if (port != null) {
try {
mt.setPort(Integer.parseInt(port));
}
catch (Exception e) {
}
mt.setPort(Integer.parseInt(port));
}
return new JingleTransport.RawUdp.Candidate(mt);
}