- Optimision fermeture resource SBE

This commit is contained in:
Benjamin 2022-03-20 12:47:44 +01:00
parent 92ca17f6df
commit b60b5ddd55
2 changed files with 4 additions and 17 deletions

View File

@ -96,13 +96,13 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable {
} catch (IOException exception) {
System.out.println("[ERROR] Problem with SBE (" + domain + ") : " + exception.getMessage());
this.close();
this.setRunning(false);
}
}
// Fermeture du SBE
try {
super.close();
this.close();
this.fileFrontEnd.onStoreDisconnect(this.domain);
} catch (Exception ioException) {
System.out.println("[ERROR] Error while closing SBE (" + domain + ") : " + ioException.getMessage());
@ -129,7 +129,7 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable {
synchronized (this) {
this.protocolResult = null;
if (responseCommand == null) {
this.close();
this.setRunning(false);
}
fileFrontEnd.onStoreAvailable(this.getDomain(), responseCommand);
}
@ -148,20 +148,6 @@ public class StoreProcessor extends UnicastThread implements AutoCloseable {
}
}
/**
* AutoClosable Function
* Close the Storage thread and resources.
*
* @since 1.0
*/
@Override
public void close() {
if (this.isRunning()) {
this.setRunning(false);
System.out.println("[SBE] Fermeture de " + domain);
}
}
/**
* Compare two StoreProcessor object to check if equals.
*/

View File

@ -78,6 +78,7 @@ public abstract class UnicastThread extends Thread implements AutoCloseable {
this.reader.close();
this.writer.close();
this.socket.close();
setRunning(false);
}
protected boolean isRunning() {