@@ -125,7 +125,8 @@ public FilterProcess<T> clone() throws CloneNotSupportedException {
125
125
@ Override
126
126
public void changeSaveOrder (String order ) throws IOException {
127
127
try {
128
- this .fileSaveMapper .changePrefixAndSuffix (processName , order );
128
+ if (nextProcessor != null ) nextProcessor .changeSaveOrder (order );
129
+ else fileSaveMapper .changePrefixAndSuffix (processName , order );
129
130
} catch (NullPointerException e ) {
130
131
throw new IOException ("instance without savePath can not call changeSaveOrder method." );
131
132
}
@@ -148,7 +149,7 @@ public String processLine(T line) throws IOException {
148
149
} else if (filter == null ) { // 如果是关闭了那么 filter 应该为 null
149
150
throw new IOException ("input is empty or the processor may be already closed." );
150
151
} else {
151
- throw new IOException ("instance without savePath can not call this batch process method." );
152
+ throw new IOException (e . getMessage () );
152
153
}
153
154
} catch (IOException e ) {
154
155
throw e ;
@@ -182,8 +183,22 @@ public void processLine(List<T> list) throws IOException {
182
183
// 默认在不进行进一步处理的情况下直接保存结果,如果需要进一步处理则不保存过滤的结果。
183
184
if (nextProcessor == null ) {
184
185
List <String > writeList = typeConverter .convertToVList (filterList );
185
- if (writeList .size () > 0 ) fileSaveMapper .writeSuccess (String .join ("\n " , writeList ), false );
186
- if (typeConverter .errorSize () > 0 ) fileSaveMapper .writeError (typeConverter .errorLines (), false );
186
+ try {
187
+ if (writeList .size () > 0 ) fileSaveMapper .writeSuccess (String .join ("\n " , writeList ), false );
188
+ if (typeConverter .errorSize () > 0 ) fileSaveMapper .writeError (typeConverter .errorLines (), false );
189
+ } catch (NullPointerException e ) {
190
+ if (canceled ) {
191
+ // // nothing to do
192
+ } else if (filter == null ) { // 如果是关闭了那么 filter 应该为 null
193
+ throw new IOException ("input is empty or the processor may be already closed." );
194
+ } else {
195
+ throw new IOException ("instance without savePath can not call this batch process method." );
196
+ }
197
+ } catch (IOException e ) {
198
+ throw e ;
199
+ } catch (Exception e ) {
200
+ throw new IOException (e .getMessage ());
201
+ }
187
202
} else {
188
203
nextProcessor .processLine (filterList );
189
204
}
@@ -194,6 +209,7 @@ public void closeResource() {
194
209
filter = null ;
195
210
if (nextProcessor != null ) nextProcessor .closeResource ();
196
211
savePath = null ;
212
+ saveIndex = null ;
197
213
if (fileSaveMapper != null ) fileSaveMapper .closeWriters ();
198
214
fileSaveMapper = null ;
199
215
typeConverter = null ;
0 commit comments