@@ -105,13 +105,16 @@ static void xml(String path, boolean isClasspath, Optilog instance) {
105105 System .err .println ("Optilog Note: Failed to read xml setting file!" );
106106 instance .consoleFileMasterCaution = false ;
107107 e .printStackTrace ();
108+ } catch (NullPointerException ignored ) {
109+
108110 }
109111 } else {
110112 try (InputStream input = new FileInputStream (path )) {
111113 XmlSettingBean object = new XmlMapper (new JacksonXmlModule ()).readValue (input , XmlSettingBean .class );
112114 // config print
113- if (object .print .get ("packingFormat" ) != null ) {
114- instance .allSetting .printPackingFormat = object .print .get ("packingFormat" ).trim ();
115+ String a = object .print .get ("packingFormat" );
116+ if (a != null ) {
117+ instance .allSetting .printPackingFormat = a .trim ();
115118 }
116119 instance .allSetting .printInfo = Boolean .parseBoolean (object .print .get ("printInfo" ).trim ());
117120 instance .allSetting .printError = Boolean .parseBoolean (object .print .get ("printError" ).trim ());
@@ -120,44 +123,57 @@ static void xml(String path, boolean isClasspath, Optilog instance) {
120123 instance .allSetting .printFatal = Boolean .parseBoolean (object .print .get ("printFatal" ).trim ());
121124
122125 // config file
123- if (object .file .get ("packingFormat" ) != null ) {
124- instance .allSetting .consolePackingFormat = object .file .get ("packingFormat" ).trim ();
126+ String b = object .file .get ("packingFormat" );
127+ if (b != null ) {
128+ instance .allSetting .consolePackingFormat = b .trim ();
125129 }
126- if (object .file .get ("defaultConsolePath" ) != null ) {
127- instance .allSetting .defaultConsolePath = object .file .get ("defaultConsolePath" ).trim ();
130+ String c = object .file .get ("defaultConsolePath" );
131+ if (c != null ) {
132+ instance .allSetting .defaultConsolePath = c .trim ();
128133 }
129- if (object .file .get ("Path1" ) != null ) {
130- instance .allSetting .Path1 = object .file .get ("Path1" ).trim ();
134+ String d = object .file .get ("Path1" );
135+ if (d != null ) {
136+ instance .allSetting .Path1 = d .trim ();
131137 }
132- if (object .file .get ("Path2" ) != null ) {
133- instance .allSetting .Path2 = object .file .get ("Path2" ).trim ();
138+ String e = object .file .get ("Path2" );
139+ if (e != null ) {
140+ instance .allSetting .Path2 = e .trim ();
134141 }
135- if (object .file .get ("Path3" ) != null ) {
136- instance .allSetting .Path3 = object .file .get ("Path3" ).trim ();
142+ String f = object .file .get ("Path3" );
143+ if (f != null ) {
144+ instance .allSetting .Path3 = f .trim ();
137145 }
138- if (object .file .get ("Path4" ) != null ) {
139- instance .allSetting .Path4 = object .file .get ("Path4" ).trim ();
146+ String g = object .file .get ("Path4" );
147+ if (g != null ) {
148+ instance .allSetting .Path4 = g .trim ();
140149 }
141- if (object .file .get ("Path5" ) != null ) {
142- instance .allSetting .Path5 = object .file .get ("Path5" ).trim ();
150+ String h = object .file .get ("Path5" );
151+ if (h != null ) {
152+ instance .allSetting .Path5 = h .trim ();
143153 }
144- if (object .file .get ("infoPath" ) != null ) {
145- instance .allSetting .infoPath = object .file .get ("infoPath" ).trim ();
154+ String i = object .file .get ("infoPath" );
155+ if (i != null ) {
156+ instance .allSetting .infoPath = i .trim ();
146157 }
147- if (object .file .get ("errorPath" ) != null ) {
148- instance .allSetting .errorPath = object .file .get ("errorPath" ).trim ();
158+ String j = object .file .get ("errorPath" );
159+ if (j != null ) {
160+ instance .allSetting .errorPath = j .trim ();
149161 }
150- if (object .file .get ("warnPath" ) != null ) {
151- instance .allSetting .warnPath = object .file .get ("warnPath" ).trim ();
162+ String k = object .file .get ("warnPath" );
163+ if (k != null ) {
164+ instance .allSetting .warnPath = k .trim ();
152165 }
153- if (object .file .get ("debugPath" ) != null ) {
154- instance .allSetting .debugPath = object .file .get ("debugPath" ).trim ();
166+ String l = object .file .get ("debugPath" );
167+ if (l != null ) {
168+ instance .allSetting .debugPath = l .trim ();
155169 }
156- if (object .file .get ("fatalPath" ) != null ) {
157- instance .allSetting .fatalPath = object .file .get ("fatalPath" ).trim ();
170+ String m = object .file .get ("fatalPath" );
171+ if (m != null ) {
172+ instance .allSetting .fatalPath = m .trim ();
158173 }
159- if (object .file .get ("fileName" ) != null ) {
160- instance .allSetting .fileName = object .file .get ("fileName" ).trim ();
174+ String n = (object .file .get ("fileName" ));
175+ if (n != null ) {
176+ instance .allSetting .fileName = n .trim ();
161177 }
162178 instance .allSetting .consoleInfo = Boolean .parseBoolean (object .file .get ("consoleInfo" ).trim ());
163179 instance .allSetting .consoleError = Boolean .parseBoolean (object .file .get ("consoleError" ).trim ());
@@ -166,25 +182,30 @@ static void xml(String path, boolean isClasspath, Optilog instance) {
166182 instance .allSetting .consoleFatal = Boolean .parseBoolean (object .file .get ("consoleFatal" ).trim ());
167183
168184 // config server
169- if (object .server .get ("packingFormat" ) != null ) {
170- instance .allSetting .serverPackingFormat = object .server .get ("packingFormat" ).trim ();
185+ String o = object .server .get ("packingFormat" );
186+ if (o != null ) {
187+ instance .allSetting .serverPackingFormat = o .trim ();
171188 }
172189 instance .allSetting .serverInfo = Boolean .parseBoolean (object .server .get ("serverInfo" ).trim ());
173190 instance .allSetting .serverError = Boolean .parseBoolean (object .server .get ("serverError" ).trim ());
174191 instance .allSetting .serverWarn = Boolean .parseBoolean (object .server .get ("serverWarn" ).trim ());
175192 instance .allSetting .serverDebug = Boolean .parseBoolean (object .server .get ("serverDebug" ).trim ());
176193 instance .allSetting .serverFatal = Boolean .parseBoolean (object .server .get ("serverFatal" ).trim ());
177194 instance .allSetting .startClient = Boolean .parseBoolean (object .server .get ("startClient" ).trim ());
178- if (object .server .get ("host" ) != null ) {
179- instance .allSetting .host = object .server .get ("host" );
195+ String p = object .server .get ("host" );
196+ if (p != null ) {
197+ instance .allSetting .host = p .trim ();
180198 }
181- if (object .server .get ("socketNumber" ) != null ) {
182- instance .allSetting .socketNumber = Integer .parseInt (object .server .get ("socketNumber" ));
199+ String q = object .server .get ("socketNumber" );
200+ if (q != null ) {
201+ instance .allSetting .socketNumber = Integer .parseInt (q .trim ());
183202 }
184203
185204 } catch (IOException e ) {
186205 System .err .println ("Optilog Note: Failed to read xml setting file!" );
187206 e .printStackTrace ();
207+ } catch (NullPointerException ignored ) {
208+
188209 }
189210 }
190211 }
0 commit comments