[openrtm-commit:02753] r1013 - in trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC: . port
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 8月 17日 (木) 14:21:18 JST
Author: t-katami
Date: 2017-08-17 14:21:18 +0900 (Thu, 17 Aug 2017)
New Revision: 1013
Modified:
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java
Log:
[compat,bugfix,->RELENG_1_2] Fixed the items pointed out by the static code analysis tool.
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2017-08-17 04:30:52 UTC (rev 1012)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/Manager.java 2017-08-17 05:21:18 UTC (rev 1013)
@@ -3630,8 +3630,9 @@
if (!(m_config.getProperty(name_conf) == null
|| m_config.getProperty(name_conf).length() == 0)) {
+ BufferedReader conff = null;
try {
- BufferedReader conff = new BufferedReader(
+ conff = new BufferedReader(
new FileReader(m_config.getProperty(name_conf)));
name_prop.load(conff);
rtcout.println(Logbuf.INFO,
@@ -3649,6 +3650,11 @@
+" in Manager.configureComponent() name_conf.");
rtcout.println(Logbuf.DEBUG, e.getMessage());
+ } catch (IOException e) {
+ rtcout.println(Logbuf.DEBUG,
+ "Exception: Caught IOException"
+ +" in Manager.configureComponent() name_prop.load().");
+ rtcout.println(Logbuf.DEBUG, e.getMessage());
} catch (Exception e) {
rtcout.println(Logbuf.DEBUG,
"Exception: Caught unknown"
@@ -3655,6 +3661,17 @@
+" in Manager.configureComponent() name_conf.");
rtcout.println(Logbuf.DEBUG, e.getMessage());
}
+ if(conff != null){
+ try {
+ conff.close();
+ }
+ catch (Exception e) {
+ rtcout.println(Logbuf.DEBUG,
+ "Exception: Caught unknown"
+ +" in Manager.configureComponent() clsoe.");
+ rtcout.println(Logbuf.DEBUG, e.getMessage());
+ }
+ }
}
if (m_config.findNode(category + "." + inst_name) != null) {
@@ -3928,13 +3945,21 @@
File otherref
= new File(m_config.getProperty("manager.refstring_path"));
if (!otherref.exists()) {
+ FileWriter reffile = null;
try {
- FileWriter reffile = new FileWriter(otherref);
+ reffile = new FileWriter(otherref);
reffile.write(
m_pORB.object_to_string(m_mgrservant.getObjRef()));
reffile.close();
} catch (IOException e) {
}
+ if(reffile != null){
+ try {
+ reffile.close();
+ }
+ catch (IOException e) {
+ }
+ }
}
else {
try{
@@ -3998,8 +4023,9 @@
if (! (fileName.length() == 0)) {
+ BufferedReader conff = null;
try {
- BufferedReader conff = new BufferedReader(new FileReader(fileName));
+ conff = new BufferedReader(new FileReader(fileName));
properties.load(conff);
conff.close();
@@ -4007,16 +4033,34 @@
} catch (FileNotFoundException e) {
rtcout.println(Logbuf.DEBUG,
- "Exception: Caught FileNotFoundException in Manager.mergeProperty().");
+ "Exception: Caught FileNotFoundException"
+ +" in Manager.mergeProperty().");
rtcout.println(Logbuf.DEBUG, e.getMessage());
e.printStackTrace();
+ } catch (IOException e) {
+ rtcout.println(Logbuf.DEBUG,
+ "Exception: Caught IOException"
+ +" in Manager.mergeProperty() properties.load().");
+ rtcout.println(Logbuf.DEBUG, e.getMessage());
} catch (Exception e) {
rtcout.println(Logbuf.DEBUG,
- "Exception: Caught unknown Exception in Manager.mergeProperty().");
+ "Exception: Caught unknown Exception"
+ +" in Manager.mergeProperty().");
rtcout.println(Logbuf.DEBUG, e.getMessage());
e.printStackTrace();
}
+ if(conff != null){
+ try {
+ conff.close();
+ }
+ catch (IOException e) {
+ rtcout.println(Logbuf.DEBUG,
+ "Exception: Caught IOException"
+ +" in Manager.mergeProperty() close().");
+ rtcout.println(Logbuf.DEBUG, e.getMessage());
+ }
+ }
}
return false;
Modified: trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java
===================================================================
--- trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java 2017-08-17 04:30:52 UTC (rev 1012)
+++ trunk/OpenRTM-aist-Java/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/port/SharedMemory.java 2017-08-17 05:21:18 UTC (rev 1013)
@@ -143,8 +143,9 @@
}
else {
address = SHARED_NAME+m_shm_address;
+ RandomAccessFile file = null;
try{
- RandomAccessFile file = new RandomAccessFile(address, "rw");
+ file = new RandomAccessFile(address, "rw");
file.setLength(m_memory_size);
file.close();
}
@@ -151,6 +152,14 @@
catch(Exception ex) {
rtcout.println(Logbuf.ERROR,"Open error "+ex.toString() );
}
+ if(file != null){
+ try{
+ file.close();
+ }
+ catch(Exception ex) {
+ rtcout.println(Logbuf.ERROR,"Close error "+ex.toString() );
+ }
+ }
}
/*
try{
@@ -213,8 +222,9 @@
}
else {
address = SHARED_NAME+m_shm_address;
+ RandomAccessFile file = null;
try{
- RandomAccessFile file = new RandomAccessFile(address, "rw");
+ file = new RandomAccessFile(address, "rw");
file.setLength(m_memory_size);
file.close();
}
@@ -221,6 +231,14 @@
catch(Exception ex) {
rtcout.println(Logbuf.ERROR,"Open error "+ex.toString() );
}
+ if(file != null){
+ try{
+ file.close();
+ }
+ catch(Exception ex) {
+ rtcout.println(Logbuf.ERROR,"Close error "+ex.toString() );
+ }
+ }
}
/*
try{
@@ -300,8 +318,9 @@
}
else {
address = SHARED_NAME+m_shm_address;
+ RandomAccessFile file = null;
try{
- RandomAccessFile file = new RandomAccessFile(address, "rw");
+ file = new RandomAccessFile(address, "rw");
FileChannel channel = file.getChannel();
int length = (int)channel.size();
MappedByteBuffer buffer
@@ -324,6 +343,14 @@
catch(Exception ex) {
rtcout.println(Logbuf.ERROR,"write error "+ex.toString() );
}
+ if(file != null){
+ try{
+ file.close();
+ }
+ catch(Exception ex) {
+ rtcout.println(Logbuf.ERROR,"close error "+ex.toString() );
+ }
+ }
}
}
/**
@@ -364,8 +391,9 @@
}
else {
address = SHARED_NAME+m_shm_address;
+ RandomAccessFile file = null;
try {
- RandomAccessFile file = new RandomAccessFile(address, "rw");
+ file = new RandomAccessFile(address, "rw");
FileChannel channel = file.getChannel();
int length = (int)channel.size();
MappedByteBuffer buffer
@@ -387,6 +415,14 @@
catch(Exception ex) {
rtcout.println(Logbuf.ERROR,"read error "+ex.toString() );
}
+ if(file != null){
+ try {
+ file.close();
+ }
+ catch(Exception ex) {
+ rtcout.println(Logbuf.ERROR,"close error "+ex.toString() );
+ }
+ }
}
}
More information about the openrtm-commit
mailing list