1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 10:37:59 +01:00

Lint fixes: Remove dead code, etc.

- make method static when possible
- remove never thrown Exception declarations
- other fixes
This commit is contained in:
Florian Schmaus 2015-03-24 18:33:47 +01:00
parent 83b84c5bd3
commit c6594aec2f
18 changed files with 48 additions and 65 deletions

View file

@ -485,7 +485,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
}
protected void bindResourceAndEstablishSession(String resource) throws XMPPErrorException,
IOException, SmackException, InterruptedException {
SmackException, InterruptedException {
// Wait until either:
// - the servers last features stanza has been parsed
@ -1392,6 +1392,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
afterFeaturesReceived();
}
@SuppressWarnings("unused")
protected void afterFeaturesReceived() throws SecurityRequiredException, NotConnectedException, InterruptedException {
// Default implementation does nothing
}

View file

@ -30,15 +30,13 @@ import java.util.Collection;
import java.util.List;
import java.util.ArrayList;
import javax.xml.parsers.ParserConfigurationException;
/**
*
*/
public class MessageTest {
@Test
public void setMessageTypeTest() throws IOException, SAXException, ParserConfigurationException {
public void setMessageTypeTest() throws IOException, SAXException {
Message.Type type = Message.Type.chat;
Message.Type type2 = Message.Type.headline;
@ -76,7 +74,7 @@ public class MessageTest {
}
@Test
public void setMessageSubjectTest() throws IOException, SAXException, ParserConfigurationException {
public void setMessageSubjectTest() throws IOException, SAXException {
final String messageSubject = "This is a test of the emergency broadcast system.";
StringBuilder controlBuilder = new StringBuilder();
@ -95,7 +93,7 @@ public class MessageTest {
}
@Test
public void oneMessageBodyTest() throws IOException, SAXException, ParserConfigurationException {
public void oneMessageBodyTest() throws IOException, SAXException {
final String messageBody = "This is a test of the emergency broadcast system.";
StringBuilder controlBuilder = new StringBuilder();
@ -114,7 +112,7 @@ public class MessageTest {
}
@Test
public void multipleMessageBodiesTest() throws IOException, SAXException, ParserConfigurationException {
public void multipleMessageBodiesTest() throws IOException, SAXException {
final String messageBody1 = "This is a test of the emergency broadcast system, 1.";
final String lang2 = "ru";
final String messageBody2 = "This is a test of the emergency broadcast system, 2.";
@ -172,7 +170,7 @@ public class MessageTest {
}
@Test
public void setMessageThreadTest() throws IOException, SAXException, ParserConfigurationException {
public void setMessageThreadTest() throws IOException, SAXException {
final String messageThread = "1234";
StringBuilder controlBuilder = new StringBuilder();
@ -191,7 +189,7 @@ public class MessageTest {
}
@Test
public void messageXmlLangTest() throws IOException, SAXException, ParserConfigurationException {
public void messageXmlLangTest() throws IOException, SAXException {
final String lang = "sp";
StringBuilder controlBuilder = new StringBuilder();

View file

@ -27,14 +27,12 @@ import org.xml.sax.SAXException;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
/**
*
*/
public class PresenceTest {
@Test
public void setPresenceTypeTest() throws IOException, SAXException, ParserConfigurationException {
public void setPresenceTypeTest() throws IOException, SAXException {
Presence.Type type = Presence.Type.unavailable;
Presence.Type type2 = Presence.Type.subscribe;
@ -81,7 +79,7 @@ public class PresenceTest {
}
@Test
public void setPresenceStatusTest() throws IOException, SAXException, ParserConfigurationException {
public void setPresenceStatusTest() throws IOException, SAXException {
final String status = "This is a test of the emergency broadcast system.";
StringBuilder controlBuilder = new StringBuilder();
@ -100,7 +98,7 @@ public class PresenceTest {
}
@Test
public void setPresencePriorityTest() throws IOException, SAXException, ParserConfigurationException {
public void setPresencePriorityTest() throws IOException, SAXException {
final int priority = 10;
StringBuilder controlBuilder = new StringBuilder();
@ -124,7 +122,7 @@ public class PresenceTest {
}
@Test
public void setPresenceModeTest() throws IOException, SAXException, ParserConfigurationException {
public void setPresenceModeTest() throws IOException, SAXException {
Presence.Mode mode1 = Presence.Mode.dnd;
final int priority = 10;
final String status = "This is a test of the emergency broadcast system.";
@ -175,7 +173,7 @@ public class PresenceTest {
}
@Test
public void presenceXmlLangTest() throws IOException, SAXException, ParserConfigurationException {
public void presenceXmlLangTest() throws IOException, SAXException {
final String lang = "sp";
StringBuilder controlBuilder = new StringBuilder();

View file

@ -66,11 +66,12 @@ public class BookmarkManager {
BookmarkManager manager = bookmarkManagerMap.get(connection);
if (manager == null) {
manager = new BookmarkManager(connection);
bookmarkManagerMap.put(connection, manager);
}
return manager;
}
private PrivateDataManager privateDataManager;
private final PrivateDataManager privateDataManager;
private Bookmarks bookmarks;
private final Object bookmarkLock = new Object();
@ -80,9 +81,8 @@ public class BookmarkManager {
*
* @param connection the connection for persisting and retrieving bookmarks.
*/
private BookmarkManager(XMPPConnection connection) throws XMPPException, SmackException {
private BookmarkManager(XMPPConnection connection) {
privateDataManager = PrivateDataManager.getInstanceFor(connection);
bookmarkManagerMap.put(connection, this);
}
/**

View file

@ -142,7 +142,7 @@ public class ChatStateManager extends Manager {
return false;
}
private void fireNewChatState(Chat chat, ChatState state) {
private static void fireNewChatState(Chat chat, ChatState state) {
for (ChatMessageListener listener : chat.getListeners()) {
if (listener instanceof ChatStateListener) {
((ChatStateListener) listener).stateChanged(chat, state);

View file

@ -574,7 +574,7 @@ public class AdHocCommandManager extends Manager {
* @param condition the condition of the error.
* @throws NotConnectedException
*/
private IQ respondError(AdHocCommandData response,
private static IQ respondError(AdHocCommandData response,
XMPPError.Condition condition) {
return respondError(response, new XMPPError(condition));
}

View file

@ -31,6 +31,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.SmackException.NoResponseException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
@ -193,10 +194,20 @@ public class IncomingFileTransfer extends FileTransfer {
try {
inputStream = streamNegotiatorTask.get(15, TimeUnit.SECONDS);
}
catch (InterruptedException e) {
throw new SmackException("Interruption while executing", e);
}
catch (ExecutionException e) {
final Throwable cause = e.getCause();
if (cause instanceof XMPPErrorException) {
throw (XMPPErrorException) cause;
}
if (cause instanceof InterruptedException) {
throw (InterruptedException) cause;
}
if (cause instanceof NoResponseException) {
throw (NoResponseException) cause;
}
if (cause instanceof SmackException) {
throw (SmackException) cause;
}
throw new SmackException("Error in execution", e);
}
catch (TimeoutException e) {

View file

@ -87,9 +87,7 @@ public abstract class StreamNegotiator {
}
protected final IQ initiateIncomingStream(final XMPPConnection connection, StreamInitiation initiation)
// CHECKSTYLE:OFF
throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// CHECKSTYLE:ON
throws NoResponseException, XMPPErrorException, NotConnectedException {
final StreamInitiation response = createInitiationAccept(initiation,
getNamespaces());

View file

@ -47,16 +47,6 @@ public class PubSub extends IQ
setType(type);
}
/**
* Returns the XML element name of the extension sub-packet root element.
*
* @return the XML element name of the stanza(/packet) extension.
*/
@SuppressWarnings("static-method")
public String getElementName() {
return ELEMENT;
}
@SuppressWarnings("unchecked")
public <PE extends ExtensionElement> PE getExtension(PubSubElementType elem)
{

View file

@ -19,7 +19,6 @@ package org.jivesoftware.smackx.xdatalayout.provider;
import java.io.IOException;
import java.util.List;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.DataFormLayoutElement;
import org.jivesoftware.smackx.xdatalayout.packet.DataLayout.Fieldref;
@ -37,8 +36,7 @@ import org.xmlpull.v1.XmlPullParserException;
*/
public class DataLayoutProvider {
public static DataLayout parse(XmlPullParser parser) throws XmlPullParserException, IOException,
SmackException {
public static DataLayout parse(XmlPullParser parser) throws XmlPullParserException, IOException {
DataLayout dataLayout = new DataLayout(parser.getAttributeValue("", "label"));
parseLayout(dataLayout.getPageLayout(), parser);
return dataLayout;

View file

@ -360,7 +360,7 @@ public class ChatManager extends Manager{
return Collections.unmodifiableSet(chatManagerListeners);
}
private void deliverMessage(Chat chat, Message message) {
private static void deliverMessage(Chat chat, Message message) {
// Here we will run any interceptors
chat.deliver(message);
}

View file

@ -177,7 +177,7 @@ public class DirectoryRosterStore implements RosterStore {
return setRosterVersion(version);
}
private Item readEntry(File file) {
private static Item readEntry(File file) {
String s = FileUtils.readFile(file);
if (s == null) {
return null;

View file

@ -322,7 +322,7 @@ public class ChatConnectionTest {
assertNull(listener.getNewChat());
}
private Message createChatPacket(final String threadId, final boolean isFullJid) {
private static Message createChatPacket(final String threadId, final boolean isFullJid) {
Message chatMsg = new Message(JidTestUtil.BARE_JID_1, Message.Type.chat);
chatMsg.setBody("the body message - " + System.currentTimeMillis());
Jid jid;

View file

@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.junit.Before;
import org.junit.Test;
@ -37,7 +36,7 @@ public class RosterOfflineTest {
Roster roster;
@Before
public void setup() throws XMPPException, SmackException {
public void setup() {
this.connection = new DummyConnection();
assertFalse(connection.isConnected());

View file

@ -32,7 +32,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import org.jivesoftware.smack.DummyConnection;
import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.im.InitSmackIm;
import org.jivesoftware.smack.packet.ErrorIQ;
import org.jivesoftware.smack.packet.IQ;
@ -511,8 +510,7 @@ public class RosterTest extends InitSmackIm {
* @param connection the dummy connection of which the provided roster belongs to.
* @param roster the roster (or buddy list) which should be initialized.
*/
public static void removeAllRosterEntries(DummyConnection connection, Roster roster)
throws InterruptedException, XMPPException {
public static void removeAllRosterEntries(DummyConnection connection, Roster roster) {
for(RosterEntry entry : roster.getEntries()) {
// prepare the roster push packet
final RosterPacket rosterPush= new RosterPacket();
@ -539,7 +537,7 @@ public class RosterTest extends InitSmackIm {
* @throws SmackException
* @throws XmppStringprepException
*/
private void initRoster() throws InterruptedException, XMPPException, SmackException, XmppStringprepException {
private void initRoster() throws InterruptedException, SmackException, XmppStringprepException {
roster.reload();
while (true) {
final Stanza sentPacket = connection.getSentPacket();

View file

@ -135,7 +135,7 @@ public class RosterVersioningTest {
* @throws XmppStringprepException
*/
@Test(timeout = 5000)
public void testOtherVersionStored() throws InterruptedException, XMPPException, SmackException, XmppStringprepException {
public void testOtherVersionStored() throws XMPPException, SmackException, XmppStringprepException {
Item vaglafItem = vaglafItem();
// We expect that the roster request is the only packet sent. This is not part of the specification,
@ -226,7 +226,7 @@ public class RosterVersioningTest {
}
}
private Item vaglafItem() throws XmppStringprepException {
private static Item vaglafItem() throws XmppStringprepException {
Item item = new Item(JidCreate.from("vaglaf@example.com"), "vaglaf the only");
item.setItemType(ItemType.both);
item.addGroupName("all");
@ -235,7 +235,7 @@ public class RosterVersioningTest {
return item;
}
private void populateStore(RosterStore store) throws IOException {
private static void populateStore(RosterStore store) throws IOException {
store.addEntry(new RosterPacket.Item(JidCreate.from("geoff@example.com"), "geoff hurley"), "");
RosterPacket.Item item = new RosterPacket.Item(JidCreate.from("joe@example.com"), "joe stevens");
@ -249,7 +249,7 @@ public class RosterVersioningTest {
store.addEntry(item, "v96");
}
private void answerWithEmptyRosterResult() throws InterruptedException {
private void answerWithEmptyRosterResult() {
// We expect that the roster request is the only packet sent. This is not part of the specification,
// but a shortcut in the test implementation.
Stanza sentPacket = connection.getSentPacket();

View file

@ -898,7 +898,7 @@ public class Base64
if( bytes != null && bytes.length >= 4 )
{
int head = ((int)bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
int head = (bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00);
if( java.util.zip.GZIPInputStream.GZIP_MAGIC == head )
{
java.io.ByteArrayInputStream bais = null;
@ -969,12 +969,10 @@ public class Base64
catch( java.io.IOException e )
{
LOGGER.log(Level.SEVERE, "Error reading object", e);
obj = null;
} // end catch
catch( java.lang.ClassNotFoundException e )
{
LOGGER.log(Level.SEVERE, "Class not found for encoded object", e);
obj = null;
} // end catch
finally
{

View file

@ -669,14 +669,8 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
KeyManager[] kms = null;
PasswordCallback pcb = null;
if(config.getCallbackHandler() == null) {
ks = null;
} else if (context == null) {
if(config.getKeystoreType().equals("NONE")) {
ks = null;
pcb = null;
}
else if(config.getKeystoreType().equals("PKCS11")) {
if (context == null) {
if(config.getKeystoreType().equals("PKCS11")) {
try {
Constructor<?> c = Class.forName("sun.security.pkcs11.SunPKCS11").getConstructor(InputStream.class);
String pkcs11Config = "name = SmartCard\nlibrary = "+config.getPKCS11Library();
@ -1710,7 +1704,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
return Math.min(clientResumptionTime, serverResumptionTime);
}
private void processHandledCount(long handledCount) throws NotConnectedException, StreamManagementCounterError {
private void processHandledCount(long handledCount) throws StreamManagementCounterError {
long ackedStanzasCount = SMUtils.calculateDelta(handledCount, serverHandledStanzasCount);
final List<Stanza> ackedStanzas = new ArrayList<Stanza>(
handledCount <= Integer.MAX_VALUE ? (int) handledCount