Skip to content

Commit 6fa8b75

Browse files
committed
CLOUDSTACK-8656: reporting ignored exceptions in server
1 parent a0ba7d3 commit 6fa8b75

4 files changed

Lines changed: 11 additions & 14 deletions

File tree

‎server/src/com/cloud/network/ExternalIpAddressAllocator.java‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// under the License.
1717
package com.cloud.network;
1818

19+
import static com.cloud.utils.AutoCloseableUtil.closeAutoCloseable;
20+
1921
import java.io.BufferedReader;
2022
import java.io.IOException;
2123
import java.io.InputStreamReader;
@@ -81,12 +83,7 @@ public IpAddr getPrivateIpAddress(String macAddr, long dcId, long podId) {
8183
} catch (IOException e) {
8284
return new IpAddr();
8385
} finally {
84-
if (in != null) {
85-
try {
86-
in.close();
87-
} catch (IOException e) {
88-
}
89-
}
86+
closeAutoCloseable(in, "closing buffered reader");
9087
}
9188

9289
}
@@ -121,12 +118,7 @@ public boolean releasePrivateIpAddress(String ip, long dcId, long podId) {
121118
} catch (IOException e) {
122119
return false;
123120
} finally {
124-
if (in != null) {
125-
try {
126-
in.close();
127-
} catch (IOException e) {
128-
}
129-
}
121+
closeAutoCloseable(in, "buffered reader close");
130122
}
131123
}
132124

‎server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ public boolean applyLBStickinessPolicy(CreateLBStickinessPolicyCmd cmd) {
693693
if (backupState.equals(FirewallRule.State.Active))
694694
applyLoadBalancerConfig(cmd.getLbRuleId());
695695
} catch (ResourceUnavailableException e1) {
696+
s_logger.info("[ignored] applying load balancer config.", e1);
696697
} finally {
697698
loadBalancer.setState(backupState);
698699
_lbDao.persist(loadBalancer);

‎server/src/com/cloud/server/ConfigurationServerImpl.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
import javax.inject.Inject;
4444
import javax.naming.ConfigurationException;
4545

46-
import com.cloud.utils.nio.Link;
4746
import org.apache.commons.codec.binary.Base64;
4847
import org.apache.commons.io.FileUtils;
4948
import org.apache.commons.lang.StringUtils;
@@ -118,6 +117,7 @@
118117
import com.cloud.utils.db.TransactionStatus;
119118
import com.cloud.utils.exception.CloudRuntimeException;
120119
import com.cloud.utils.net.NetUtils;
120+
import com.cloud.utils.nio.Link;
121121
import com.cloud.utils.script.Script;
122122

123123
public class ConfigurationServerImpl extends ManagerBase implements ConfigurationServer {
@@ -757,6 +757,7 @@ public void updateKeyPairs() {
757757
try (DataInputStream dis = new DataInputStream(new FileInputStream(privkeyfile))) {
758758
dis.readFully(arr1);
759759
} catch (EOFException e) {
760+
s_logger.info("[ignored] eof reached");
760761
} catch (Exception e) {
761762
s_logger.error("Cannot read the private key file", e);
762763
throw new CloudRuntimeException("Cannot read the private key file");
@@ -766,6 +767,7 @@ public void updateKeyPairs() {
766767
try (DataInputStream dis = new DataInputStream(new FileInputStream(pubkeyfile))) {
767768
dis.readFully(arr2);
768769
} catch (EOFException e) {
770+
s_logger.info("[ignored] eof reached");
769771
} catch (Exception e) {
770772
s_logger.warn("Cannot read the public key file", e);
771773
throw new CloudRuntimeException("Cannot read the public key file");
@@ -902,7 +904,7 @@ protected void injectSshKeysIntoSystemVmIsoPatch(String publicKeyPath, String pr
902904
} else {
903905
command = new Script("/bin/bash", s_logger);
904906
}
905-
if (this.isOnWindows()) {
907+
if (isOnWindows()) {
906908
scriptPath = scriptPath.replaceAll("\\\\" ,"/" );
907909
systemVmIsoPath = systemVmIsoPath.replaceAll("\\\\" ,"/" );
908910
publicKeyPath = publicKeyPath.replaceAll("\\\\" ,"/" );

‎server/src/com/cloud/servlet/ConsoleProxyServlet.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,14 @@ private void handleThumbnailRequest(HttpServletRequest req, HttpServletResponse
228228
try {
229229
w = Integer.parseInt(value);
230230
} catch (NumberFormatException e) {
231+
s_logger.info("[ignored] not a number: " + value);
231232
}
232233

233234
value = req.getParameter("h");
234235
try {
235236
h = Integer.parseInt(value);
236237
} catch (NumberFormatException e) {
238+
s_logger.info("[ignored] not a number: " + value);
237239
}
238240

239241
try {

0 commit comments

Comments
 (0)