Skip to content

Commit

Permalink
fix: Fixes warning and NPE exceptions in SmackDebugger.
Browse files Browse the repository at this point in the history
  • Loading branch information
damencho committed May 20, 2022
1 parent f77a99d commit fb76d17
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 49 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<properties>
<assembly.skipAssembly>true</assembly.skipAssembly>
<jitsi-desktop.version>2.14.645810ca9</jitsi-desktop.version>
<jitsi-desktop.version>2.14.a4c96fe56</jitsi-desktop.version>
<jitsi-desktop.groupId>org.jitsi.desktop</jitsi-desktop.groupId>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.7.36</slf4j.version>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jitsi/jigasi/CallContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
*/
package org.jitsi.jigasi;

import org.apache.commons.lang3.StringUtils;
import com.google.common.base.*;

import org.jitsi.utils.*;
import org.jitsi.utils.logging.*;
import org.jxmpp.jid.*;
import org.jxmpp.jid.impl.*;
Expand Down Expand Up @@ -534,7 +534,7 @@ else if (this.domain != null && strippedMucAddress.endsWith(this.domain)
}

// if boshURL or domain missing, do nothing
if (boshURL != null && !StringUtils.isNullOrEmpty(domain))
if (boshURL != null && StringUtils.isNotEmpty(StringUtils.trim(domain)))
{
String boshHost = domain;

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jitsi/jigasi/JvbConference.java
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,8 @@ private class RoomConfigurationChangeListener
@Override
public void processStanza(Stanza stanza)
{
MUCUser mucUser = stanza.getExtension(MUCInitialPresence.ELEMENT, MUCInitialPresence.NAMESPACE);
MUCUser mucUser = stanza.getExtension(MUCUser.class);

if (mucUser == null)
{
return;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jitsi/jigasi/ServerSecurityAuthority.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package org.jitsi.jigasi;

import net.java.sip.communicator.service.protocol.*;
import org.apache.commons.lang3.*;
import org.jitsi.utils.logging.*;
import org.jitsi.utils.*;

/**
* No UI just returns default credentials.
Expand Down Expand Up @@ -63,7 +63,7 @@ public UserCredentials obtainCredentials(String realm,
return null;
}

if (!StringUtils.isNullOrEmpty(password))
if (StringUtils.isNotEmpty(StringUtils.trim(password)))
{
defaultValues.setPassword(password.toCharArray());
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/jitsi/jigasi/SipGatewaySession.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.media.*;
import org.apache.commons.lang3.StringUtils;
import org.jitsi.impl.neomedia.*;
import org.jitsi.jigasi.sip.*;
import org.jitsi.jigasi.sounds.*;
Expand Down Expand Up @@ -1438,7 +1439,7 @@ else if (call.getCallState() == CallState.CALL_ENDED)
&& jvbConference != null && jvbConference.isInTheRoom())
{
// Show reason instead of disconnected
if (!StringUtils.isNullOrEmpty(cause.getReasonString()))
if (StringUtils.isNotEmpty(StringUtils.trim(cause.getReasonString())))
{
jvbConference.setPresenceStatus(
cause.getReasonString());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jitsi/jigasi/TranscriptionGateway.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public TranscriptionGatewaySession createOutgoingCall(CallContext ctx)
try
{
service = (TranscriptionService)Class.forName(
customTranscriptionServiceClass).newInstance();
customTranscriptionServiceClass).getDeclaredConstructor().newInstance();
}
catch(Exception e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.java.sip.communicator.service.protocol.*;
import net.java.sip.communicator.service.protocol.event.*;
import net.java.sip.communicator.service.protocol.media.*;
import org.apache.commons.lang3.StringUtils;
import org.jitsi.jigasi.*;
import org.jitsi.jigasi.sounds.*;
import org.jitsi.jigasi.transcription.*;
Expand Down Expand Up @@ -163,7 +164,7 @@ static SipHealthPeriodicChecker create(SipGateway gw)

healthCheckSipUri = conf.getString(PROP_HEALTH_CHECK_SIP_URI);

if (StringUtils.isNullOrEmpty(healthCheckSipUri))
if (StringUtils.isEmpty(StringUtils.trim(healthCheckSipUri)))
{
logger.warn(
"No health check started, no HEALTH_CHECK_SIP_URI prop.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,7 @@ private CallContext getCallContext()
*/
public void process(Presence presence)
{
RecordingStatus rs = presence.getExtension(
RecordingStatus.ELEMENT,
RecordingStatus.NAMESPACE);
RecordingStatus rs = presence.getExtension(RecordingStatus.class);

if (rs != null
&& gatewaySession.getFocusResourceAddr().equals(
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jitsi/jigasi/stats/Statistics.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

import net.java.sip.communicator.impl.protocol.jabber.*;
import net.java.sip.communicator.util.osgi.ServiceUtils;
import org.apache.commons.lang3.*;
import org.eclipse.jetty.server.*;
import org.jitsi.jigasi.version.*;
import org.jitsi.utils.*;
import org.jitsi.utils.logging.Logger;
import org.osgi.framework.*;
import org.json.simple.*;
Expand Down Expand Up @@ -496,7 +496,7 @@ private static void updatePresenceStatusForXmppProvider(

String region = JigasiBundleActivator.getConfigurationService()
.getString(LOCAL_REGION_PNAME);
if (!StringUtils.isNullOrEmpty(region))
if (StringUtils.isNotEmpty(StringUtils.trim(region)))
{
stats.addStat(new ColibriStatsExtension.Stat(
REGION,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ private RecognitionConfig getRecognitionConfig(TranscriptionRequest request)

// Set the sampling rate and encoding of the audio
AudioFormat format = request.getFormat();
builder.setSampleRateHertz(new Double(format.getSampleRate())
.intValue());
builder.setSampleRateHertz(Double.valueOf(format.getSampleRate()).intValue());
switch(format.getEncoding())
{
case "LINEAR":
Expand Down
29 changes: 3 additions & 26 deletions src/main/java/org/jitsi/jigasi/transcription/Participant.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,7 @@ public String getIdentityGroupId()
*/
private IdentityPacketExtension getIdentityExtensionOrNull(Presence p)
{
return p.getExtension(IdentityPacketExtension.ELEMENT,
IdentityPacketExtension.NAMESPACE);
return p.getExtension(IdentityPacketExtension.class);
}

/**
Expand All @@ -383,16 +382,14 @@ private IdentityPacketExtension getIdentityExtensionOrNull(Presence p)
*/
private AvatarIdPacketExtension getAvatarIdExtensionOrNull(Presence p)
{
return p.getExtension(AvatarIdPacketExtension.ELEMENT,
AvatarIdPacketExtension.NAMESPACE);
return p.getExtension(AvatarIdPacketExtension.class);
}

private TranscriptionRequestExtension
getTranscriptionRequestExtensionOrNull(Presence p)
{
return p != null
? p.getExtension(TranscriptionRequestExtension.ELEMENT,
TranscriptionRequestExtension.NAMESPACE)
? p.getExtension(TranscriptionRequestExtension.class)
: null;
}

Expand Down Expand Up @@ -470,16 +467,6 @@ public void setConfMember(ConferenceMember confMember)
this.confMember = confMember;
}

/**
* Get the {@link ConferenceMember} belonging to this participant
*
* @return the conference member
*/
public ConferenceMember getConfMember()
{
return confMember;
}

/**
* Set the {@link ChatRoomMember} belonging to this participant
*
Expand All @@ -490,16 +477,6 @@ public void setChatMember(ChatRoomMember chatMember)
this.chatMember = chatMember;
}

/**
* Get the {@link ChatRoomMember} belonging to this participant
*
* @return the chatroom member
*/
public ChatRoomMember getChatMember()
{
return chatMember;
}

/**
* Get the identifier in the JID of this participant
*
Expand Down
8 changes: 2 additions & 6 deletions src/main/java/org/jitsi/jigasi/transcription/Transcriber.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,14 +324,10 @@ public void updateParticipant(String identifier,
Presence presence = ((ChatRoomMemberJabberImpl) chatRoomMember).getLastPresence();

TranscriptionLanguageExtension transcriptionLanguageExtension
= presence.getExtension(
TranscriptionLanguageExtension.ELEMENT,
TranscriptionLanguageExtension.NAMESPACE);
= presence.getExtension(TranscriptionLanguageExtension.class);

TranslationLanguageExtension translationLanguageExtension
= presence.getExtension(
TranslationLanguageExtension.ELEMENT,
TranslationLanguageExtension.NAMESPACE);
= presence.getExtension(TranslationLanguageExtension.class);

if (transcriptionLanguageExtension != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ private IQ processIQInternal(DialIq packet, CallContext ctx)
{
logger.error(ctx + " Error processing RayoIq", e);
return IQ.createErrorResponse(packet, StanzaError.from(
StanzaError.Condition.internal_server_error, e.getMessage()));
StanzaError.Condition.internal_server_error, e.getMessage()).build());
}
}

Expand Down

0 comments on commit fb76d17

Please sign in to comment.