mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-21 22:02:06 +01:00
Add errorprone check and fix found errors
Adds gradle-errorprone-plugin 0.0.8, requires Gradle 2.6.
This commit is contained in:
parent
8096da43e0
commit
d728204890
23 changed files with 64 additions and 44 deletions
|
@ -3,12 +3,14 @@ import org.gradle.plugins.signing.Sign
|
|||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
maven { url 'https://plugins.gradle.org/m2/' }
|
||||
maven { url 'http://dl.bintray.com/content/aalmiray/kordamp' }
|
||||
}
|
||||
dependencies {
|
||||
classpath 'org.kordamp:markdown-gradle-plugin:1.0.0'
|
||||
classpath 'org.kordamp.gradle:clirr-gradle-plugin:0.2.0'
|
||||
classpath "org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.3.1"
|
||||
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.8'
|
||||
}
|
||||
}
|
||||
apply plugin: 'org.kordamp.gradle.markdown'
|
||||
|
@ -19,6 +21,7 @@ allprojects {
|
|||
apply plugin: 'java'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'jacoco'
|
||||
apply plugin: 'net.ltgt.errorprone'
|
||||
|
||||
ext {
|
||||
gitCommit = getGitCommit()
|
||||
|
@ -127,6 +130,11 @@ allprojects {
|
|||
// e.g. JAVA7_HOME. See SMACK-651.
|
||||
'-Xlint:-options',
|
||||
'-Werror',
|
||||
// Needed because since adding gradle-errorprone-plugin
|
||||
// See https://github.com/tbroyer/gradle-errorprone-plugin/issues/15
|
||||
'-Xlint:-path',
|
||||
// Disable errorprone checks
|
||||
'-Xep:TypeParameterUnusedInFormals:OFF',
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
*/
|
||||
protected String sessionID = null;
|
||||
|
||||
private boolean notified;
|
||||
|
||||
/**
|
||||
* Create a HTTP Binding connection to an XMPP server.
|
||||
*
|
||||
|
@ -135,6 +137,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
@Override
|
||||
protected void connectInternal() throws SmackException, InterruptedException {
|
||||
done = false;
|
||||
notified = false;
|
||||
try {
|
||||
// Ensure a clean starting state
|
||||
if (client != null) {
|
||||
|
@ -179,10 +182,12 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
// Wait for the response from the server
|
||||
synchronized (this) {
|
||||
if (!connected) {
|
||||
try {
|
||||
wait(getPacketReplyTimeout());
|
||||
final long deadline = System.currentTimeMillis() + getPacketReplyTimeout();
|
||||
while (!notified) {
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > deadline) break;
|
||||
wait(deadline - now);
|
||||
}
|
||||
catch (InterruptedException e) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,6 +444,7 @@ public class XMPPBOSHConnection extends AbstractXMPPConnection {
|
|||
}
|
||||
}
|
||||
finally {
|
||||
notified = true;
|
||||
synchronized (XMPPBOSHConnection.this) {
|
||||
XMPPBOSHConnection.this.notifyAll();
|
||||
}
|
||||
|
|
|
@ -192,8 +192,13 @@ public final class SASLAuthentication {
|
|||
else {
|
||||
currentMechanism.authenticate(username, host, xmppServiceDomain, password);
|
||||
}
|
||||
final long deadline = System.currentTimeMillis() + connection.getPacketReplyTimeout();
|
||||
while (!authenticationSuccessful && saslException == null) {
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > deadline) break;
|
||||
// Wait until SASL negotiation finishes
|
||||
wait(connection.getPacketReplyTimeout());
|
||||
wait(deadline - now);
|
||||
}
|
||||
}
|
||||
|
||||
if (saslException != null){
|
||||
|
|
|
@ -71,7 +71,12 @@ class HTTPProxySocketConnection implements ProxySocketConnection {
|
|||
|
||||
while (true)
|
||||
{
|
||||
char c = (char) in.read();
|
||||
int inByte = in.read();
|
||||
if (inByte == -1)
|
||||
{
|
||||
throw new ProxyException(ProxyInfo.ProxyType.HTTP);
|
||||
}
|
||||
char c = (char) inByte;
|
||||
got.append(c);
|
||||
if (got.length() > 1024)
|
||||
{
|
||||
|
@ -79,10 +84,6 @@ class HTTPProxySocketConnection implements ProxySocketConnection {
|
|||
"header of >1024 characters from "
|
||||
+ proxyhost + ", cancelling connection");
|
||||
}
|
||||
if (c == -1)
|
||||
{
|
||||
throw new ProxyException(ProxyInfo.ProxyType.HTTP);
|
||||
}
|
||||
if ((nlchars == 0 || nlchars == 2) && c == '\r')
|
||||
{
|
||||
nlchars++;
|
||||
|
|
|
@ -31,7 +31,7 @@ import java.util.List;
|
|||
public class ObservableReader extends Reader {
|
||||
|
||||
Reader wrappedReader = null;
|
||||
List<ReaderListener> listeners = new ArrayList<ReaderListener>();
|
||||
final List<ReaderListener> listeners = new ArrayList<ReaderListener>();
|
||||
|
||||
public ObservableReader(Reader wrappedReader) {
|
||||
this.wrappedReader = wrappedReader;
|
||||
|
|
|
@ -31,7 +31,7 @@ public class ObservableWriter extends Writer {
|
|||
private static final int MAX_STRING_BUILDER_SIZE = 4096;
|
||||
|
||||
Writer wrappedWriter = null;
|
||||
List<WriterListener> listeners = new ArrayList<WriterListener>();
|
||||
final List<WriterListener> listeners = new ArrayList<WriterListener>();
|
||||
private final StringBuilder stringBuilder = new StringBuilder(MAX_STRING_BUILDER_SIZE);
|
||||
|
||||
public ObservableWriter(Writer wrappedWriter) {
|
||||
|
|
|
@ -75,7 +75,6 @@ class Socks5Client {
|
|||
*/
|
||||
public Socket getSocket(int timeout) throws IOException, XMPPErrorException, InterruptedException,
|
||||
TimeoutException, SmackException, XMPPException {
|
||||
|
||||
// wrap connecting in future for timeout
|
||||
FutureTask<Socket> futureTask = new FutureTask<Socket>(new Callable<Socket>() {
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class OfflineMessageRequest extends IQ {
|
|||
public static final String ELEMENT = "offline";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/offline";
|
||||
|
||||
private List<Item> items = new ArrayList<Item>();
|
||||
private final List<Item> items = new ArrayList<>();
|
||||
private boolean purge = false;
|
||||
private boolean fetch = false;
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class DataForm implements ExtensionElement {
|
|||
|
||||
private Type type;
|
||||
private String title;
|
||||
private List<String> instructions = new ArrayList<String>();
|
||||
private final List<String> instructions = new ArrayList<>();
|
||||
private ReportedData reportedData;
|
||||
private final List<Item> items = new ArrayList<Item>();
|
||||
private final Map<String, FormField> fields = new LinkedHashMap<>();
|
||||
|
@ -197,7 +197,10 @@ public class DataForm implements ExtensionElement {
|
|||
* @param instructions list of instructions that explain how to fill out the form.
|
||||
*/
|
||||
public void setInstructions(List<String> instructions) {
|
||||
this.instructions = instructions;
|
||||
synchronized (this.instructions) {
|
||||
this.instructions.clear();
|
||||
this.instructions.addAll(instructions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,7 +40,7 @@ public class XHTMLExtension implements ExtensionElement {
|
|||
public static final String ELEMENT = "html";
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/xhtml-im";
|
||||
|
||||
private List<CharSequence> bodies = new ArrayList<CharSequence>();
|
||||
private final List<CharSequence> bodies = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Returns the XML element name of the extension sub-packet root element.
|
||||
|
|
|
@ -173,6 +173,7 @@ public final class Socks5TestProxy {
|
|||
* @param digest identifying the connection
|
||||
* @return socket or null if there is no socket for the given digest
|
||||
*/
|
||||
@SuppressWarnings("WaitNotInLoop")
|
||||
public Socket getSocket(String digest) {
|
||||
synchronized(this) {
|
||||
if (!startupComplete) {
|
||||
|
@ -180,13 +181,12 @@ public final class Socks5TestProxy {
|
|||
wait(5000);
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.log(Level.SEVERE, "exception", e);
|
||||
} finally {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!startupComplete) {
|
||||
throw new IllegalStateException("Startup of Socks5TestProxy failed within 5 seconds");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.connectionMap.get(digest);
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ public class SmackIntegrationTestFramework {
|
|||
return testRunResult;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "Finally"})
|
||||
private void runTests(Set<Class<? extends AbstractSmackIntTest>> classes)
|
||||
throws NoResponseException, NotConnectedException, InterruptedException {
|
||||
for (Class<? extends AbstractSmackIntTest> testClass : classes) {
|
||||
|
|
|
@ -33,7 +33,12 @@ public class ResultSyncPoint<R, E extends Exception> {
|
|||
if (exception != null) {
|
||||
throw exception;
|
||||
}
|
||||
wait(timeout);
|
||||
final long deadline = System.currentTimeMillis() + timeout;
|
||||
while (result == null && exception == null) {
|
||||
final long now = System.currentTimeMillis();
|
||||
if (now > deadline) break;
|
||||
wait(deadline - now);
|
||||
}
|
||||
}
|
||||
if (result != null) {
|
||||
return result;
|
||||
|
|
|
@ -184,8 +184,8 @@ public class XmppHostnameVerifier implements HostnameVerifier {
|
|||
}
|
||||
|
||||
private static boolean matchesPerRfc2818(String name, String template) {
|
||||
String[] nameParts = name.toLowerCase(Locale.US).split(".");
|
||||
String[] templateParts = template.toLowerCase(Locale.US).split(".");
|
||||
String[] nameParts = name.toLowerCase(Locale.US).split("\\.");
|
||||
String[] templateParts = template.toLowerCase(Locale.US).split("\\.");
|
||||
|
||||
if (nameParts.length != templateParts.length) {
|
||||
return false;
|
||||
|
|
|
@ -183,6 +183,7 @@ import org.jxmpp.jid.Jid;
|
|||
* @see JingleMediaManager
|
||||
* @see BasicTransportManager , STUNTransportManager, BridgedTransportManager, TransportResolver, BridgedResolver, ICEResolver, STUNResolver and BasicResolver.
|
||||
*/
|
||||
@SuppressWarnings("SynchronizeOnNonFinalField")
|
||||
public class JingleManager implements JingleSessionListener {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(JingleManager.class.getName());
|
||||
|
|
|
@ -51,7 +51,7 @@ public class AudioReceiver implements ReceiveStreamListener, SessionListener,
|
|||
|
||||
boolean dataReceived = false;
|
||||
|
||||
Object dataSync;
|
||||
final Object dataSync;
|
||||
JingleMediaSession jingleMediaSession;
|
||||
|
||||
public AudioReceiver(final Object dataSync, final JingleMediaSession jingleMediaSession) {
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.jxmpp.jid.Jid;
|
|||
* @author Thiago Camargo
|
||||
* @author Alvaro Saurin
|
||||
*/
|
||||
@SuppressWarnings("EqualsHashCode")
|
||||
public abstract class TransportCandidate {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(TransportCandidate.class.getName());
|
||||
|
|
|
@ -55,8 +55,8 @@ public class AgentRoster {
|
|||
|
||||
private XMPPConnection connection;
|
||||
private Jid workgroupJID;
|
||||
private List<String> entries;
|
||||
private List<AgentRosterListener> listeners;
|
||||
private final List<String> entries = new ArrayList<String>();
|
||||
private final List<AgentRosterListener> listeners = new ArrayList<>();
|
||||
private final Map<Jid, Map<Resourcepart, Presence>> presenceMap = new HashMap<>();
|
||||
// The roster is marked as initialized when at least a single roster packet
|
||||
// has been recieved and processed.
|
||||
|
@ -72,8 +72,6 @@ public class AgentRoster {
|
|||
AgentRoster(XMPPConnection connection, Jid workgroupJID) throws NotConnectedException, InterruptedException {
|
||||
this.connection = connection;
|
||||
this.workgroupJID = workgroupJID;
|
||||
entries = new ArrayList<String>();
|
||||
listeners = new ArrayList<AgentRosterListener>();
|
||||
// Listen for any roster packets.
|
||||
StanzaFilter rosterFilter = new StanzaTypeFilter(AgentStatusRequest.class);
|
||||
connection.addAsyncStanzaListener(new AgentStatusListener(), rosterFilter);
|
||||
|
|
|
@ -47,11 +47,10 @@ public class AgentStatusRequest extends IQ {
|
|||
*/
|
||||
public static final String NAMESPACE = "http://jabber.org/protocol/workgroup";
|
||||
|
||||
private Set<Item> agents;
|
||||
private final Set<Item> agents = new HashSet<>();
|
||||
|
||||
public AgentStatusRequest() {
|
||||
super(ELEMENT_NAME, NAMESPACE);
|
||||
agents = new HashSet<Item>();
|
||||
}
|
||||
|
||||
public int getAgentCount() {
|
||||
|
|
|
@ -132,7 +132,7 @@ public class OccupantsInfo extends IQ {
|
|||
public static class Provider extends IQProvider<OccupantsInfo> {
|
||||
|
||||
@Override
|
||||
public OccupantsInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException {
|
||||
public OccupantsInfo parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
|
||||
OccupantsInfo occupantsInfo = new OccupantsInfo(parser.getAttributeValue("", "roomID"));
|
||||
|
||||
boolean done = false;
|
||||
|
@ -149,7 +149,7 @@ public class OccupantsInfo extends IQ {
|
|||
return occupantsInfo;
|
||||
}
|
||||
|
||||
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
private OccupantInfo parseOccupantInfo(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
|
||||
|
||||
boolean done = false;
|
||||
String jid = null;
|
||||
|
@ -167,7 +167,7 @@ public class OccupantsInfo extends IQ {
|
|||
try {
|
||||
joined = UTC_FORMAT.parse(parser.nextText());
|
||||
} catch (ParseException e) {
|
||||
new SmackException(e);
|
||||
throw new SmackException(e);
|
||||
}
|
||||
} else if (eventType == XmlPullParser.END_TAG &&
|
||||
"occupant".equals(parser.getName())) {
|
||||
|
|
|
@ -56,14 +56,7 @@ public final class QueueDetails implements ExtensionElement {
|
|||
/**
|
||||
* The list of users in the queue.
|
||||
*/
|
||||
private Set<QueueUser> users;
|
||||
|
||||
/**
|
||||
* Creates a new QueueDetails packet
|
||||
*/
|
||||
private QueueDetails() {
|
||||
users = new HashSet<QueueUser>();
|
||||
}
|
||||
private final Set<QueueUser> users = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Returns the number of users currently in the queue that are waiting to
|
||||
|
|
|
@ -50,7 +50,7 @@ import java.util.List;
|
|||
*/
|
||||
public class RosterExchange implements ExtensionElement {
|
||||
|
||||
private List<RemoteRosterEntry> remoteRosterEntries = new ArrayList<RemoteRosterEntry>();
|
||||
private final List<RemoteRosterEntry> remoteRosterEntries = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Creates a new empty roster exchange package.
|
||||
|
|
|
@ -105,6 +105,7 @@ public class PacketWriterTest {
|
|||
|
||||
public class BlockingStringWriter extends Writer {
|
||||
@Override
|
||||
@SuppressWarnings("WaitNotInLoop")
|
||||
public void write(char[] cbuf, int off, int len) throws IOException {
|
||||
try {
|
||||
wait();
|
||||
|
|
Loading…
Reference in a new issue