mirror of
https://github.com/igniterealtime/Spark.git
synced 2026-02-05 01:15:40 +00:00
SPARK-1469: Code cleanup: fix error handling.
This commit is contained in:
@ -780,6 +780,7 @@ public class LoginDialog {
|
||||
loginButton.setEnabled(true);
|
||||
}
|
||||
} catch (Exception e1) {
|
||||
Log.error(e1);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@ -80,7 +80,7 @@ public class SparkCompatibility {
|
||||
}
|
||||
String[] children = src.list();
|
||||
for (int i=0; i<children.length; i++) {
|
||||
// Skip any directories / files which may need to be skipped.
|
||||
// Skip any directories / files which may need to be skipped.
|
||||
if (!skipFiles.contains((new File(dest, children[i]).getAbsolutePath()))) {
|
||||
copyDirectory(new File(src, children[i]),
|
||||
new File(dest, children[i]), new HashSet<>());
|
||||
@ -95,15 +95,13 @@ public class SparkCompatibility {
|
||||
out = new FileOutputStream(dest);
|
||||
} catch (FileNotFoundException e) {
|
||||
IOException wrapper = new IOException("copyDirectory: Unable to open handle on file: "
|
||||
+ src.getAbsolutePath() + "and" + dest.getAbsolutePath() + ".");
|
||||
wrapper.initCause(e);
|
||||
wrapper.setStackTrace(e.getStackTrace());
|
||||
throw wrapper;
|
||||
+ src.getAbsolutePath() + "and" + dest.getAbsolutePath() + ".", e);
|
||||
wrapper.setStackTrace(e.getStackTrace());
|
||||
throw wrapper;
|
||||
} catch (SecurityException e) {
|
||||
IOException wrapper = new IOException("copyDirectory: access denied to copy file: "
|
||||
+ src.getAbsolutePath() + "and" + dest.getAbsolutePath() + ".");
|
||||
wrapper.initCause(e);
|
||||
wrapper.setStackTrace(e.getStackTrace());
|
||||
+ src.getAbsolutePath() + "and" + dest.getAbsolutePath() + ".", e);
|
||||
wrapper.setStackTrace(e.getStackTrace());
|
||||
throw wrapper;
|
||||
}
|
||||
try {
|
||||
@ -115,10 +113,9 @@ public class SparkCompatibility {
|
||||
}
|
||||
} catch (IOException e) {
|
||||
IOException wrapper = new IOException("copyDirectory: Unable to copy file: "
|
||||
+ src.getAbsolutePath() + "to" + dest.getAbsolutePath() + ".");
|
||||
wrapper.initCause(e);
|
||||
wrapper.setStackTrace(e.getStackTrace());
|
||||
throw wrapper;
|
||||
+ src.getAbsolutePath() + "to" + dest.getAbsolutePath() + ".", e);
|
||||
wrapper.setStackTrace(e.getStackTrace());
|
||||
throw wrapper;
|
||||
} finally {
|
||||
in.close();
|
||||
out.close();
|
||||
|
||||
@ -31,6 +31,7 @@ import javax.swing.JTextArea;
|
||||
import org.jivesoftware.resource.SparkRes;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
|
||||
/**
|
||||
* Class to Send Raw packets useful when debugging
|
||||
@ -110,12 +111,12 @@ public class RawPacketSender implements ActionListener {
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
SparkManager.getConnection().sendStanza(stanza);
|
||||
_textarea.append("\n" + _inputarea.getText());
|
||||
} catch (Exception exc) {
|
||||
|
||||
}
|
||||
try {
|
||||
SparkManager.getConnection().sendStanza(stanza);
|
||||
_textarea.append("\n" + _inputarea.getText());
|
||||
} catch (Exception exc) {
|
||||
Log.error(exc);
|
||||
}
|
||||
}
|
||||
else if (e.getSource().equals(_clear)) {
|
||||
_textarea.setText("");
|
||||
|
||||
@ -978,16 +978,13 @@ public class ConferenceRoomBrowser extends JPanel implements ActionListener,
|
||||
* @return
|
||||
*/
|
||||
private boolean isPasswordProtected(EntityBareJid roomjid) {
|
||||
boolean result = false;
|
||||
try {
|
||||
|
||||
RoomInfo rif = MultiUserChatManager.getInstanceFor( SparkManager.getConnection() ).getRoomInfo( roomjid );
|
||||
|
||||
result = rif.isMembersOnly() || rif.isPasswordProtected();
|
||||
|
||||
} catch (XMPPException | SmackException | NumberFormatException | InterruptedException e) {
|
||||
|
||||
}
|
||||
boolean result = false;
|
||||
try {
|
||||
RoomInfo rif = MultiUserChatManager.getInstanceFor(SparkManager.getConnection()).getRoomInfo(roomjid);
|
||||
result = rif.isMembersOnly() || rif.isPasswordProtected();
|
||||
} catch (XMPPException | SmackException | NumberFormatException | InterruptedException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -696,24 +696,23 @@ public final class GraphicUtils {
|
||||
* @return byte[]
|
||||
*/
|
||||
public static byte[] getBytesFromImage(File file) {
|
||||
FileInputStream fileInputStream = null;
|
||||
FileInputStream fileInputStream = null;
|
||||
try {
|
||||
fileInputStream = new FileInputStream(file);
|
||||
byte[] data = new byte[(int) file.length()];
|
||||
fileInputStream.read(data);
|
||||
fileInputStream.close();
|
||||
return data;
|
||||
} catch (IOException e) {
|
||||
if (fileInputStream != null) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException e1) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
fileInputStream.read(data);
|
||||
fileInputStream.close();
|
||||
return data;
|
||||
} catch (IOException e) {
|
||||
if (fileInputStream != null) {
|
||||
try {
|
||||
fileInputStream.close();
|
||||
} catch (IOException e1) {
|
||||
Log.error(e1);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -24,20 +24,16 @@ import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.jid.parts.Localpart;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ChatArgumentsPlugin implements Plugin {
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
EntityBareJid start_chat_jid = null;
|
||||
try {
|
||||
start_chat_jid = JidCreate.entityBareFromUnescaped(Spark.getArgumentValue("start_chat_jid"));
|
||||
} catch (XmppStringprepException e1) {
|
||||
}
|
||||
EntityBareJid start_chat_muc = null;
|
||||
try {
|
||||
start_chat_muc = JidCreate.entityBareFromUnescaped(Spark.getArgumentValue("start_chat_muc"));
|
||||
} catch (XmppStringprepException e) {
|
||||
}
|
||||
EntityBareJid start_chat_jid = JidCreate.entityBareFromUnescapedOrThrowUnchecked(
|
||||
Objects.requireNonNull(Spark.getArgumentValue("start_chat_jid")));
|
||||
EntityBareJid start_chat_muc = JidCreate.entityBareFromUnescapedOrThrowUnchecked(
|
||||
Objects.requireNonNull(Spark.getArgumentValue("start_chat_muc")));
|
||||
|
||||
if (start_chat_jid != null) {
|
||||
Localpart nickname = start_chat_jid.getLocalpart();
|
||||
@ -47,7 +43,6 @@ public class ChatArgumentsPlugin implements Plugin {
|
||||
if (start_chat_muc != null) {
|
||||
ConferenceUtils.joinConferenceOnSeperateThread(start_chat_muc, start_chat_muc, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -18,6 +18,7 @@ package com.jivesoftware.spark.plugin.apple;
|
||||
import org.jivesoftware.spark.SparkManager;
|
||||
|
||||
import com.apple.eawt.Application;
|
||||
import org.jivesoftware.spark.util.log.Log;
|
||||
|
||||
/**
|
||||
* Utilities for dealing with the apple dock icon
|
||||
@ -32,40 +33,35 @@ public final class AppleBounce {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public AppleBounce(AppleProperties props) {
|
||||
_app = new Application();
|
||||
_props = props;
|
||||
|
||||
final Thread iconThread = new Thread(new Runnable() {
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
if (!_flash) {
|
||||
setDockBadge(_app, getMessageCount());
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
} else {
|
||||
|
||||
setDockBadge(_app, getMessageCount());
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
setDockBadge(_app, getMessageCount());
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
iconThread.start();
|
||||
_app = new Application();
|
||||
_props = props;
|
||||
|
||||
final Thread iconThread = new Thread(() -> {
|
||||
while (true) {
|
||||
if (!_flash) {
|
||||
setDockBadge(_app, getMessageCount());
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
} else {
|
||||
setDockBadge(_app, getMessageCount());
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
setDockBadge(_app, getMessageCount());
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
Log.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
iconThread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user