git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@560693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2007-07-29 08:54:49 +00:00
parent 3b73e60233
commit 1e3e5b7223
1 changed files with 20 additions and 5 deletions

View File

@ -1063,12 +1063,27 @@ public class BrokerService implements Service {
*/ */
public synchronized Store getTempDataStore(){ public synchronized Store getTempDataStore(){
if(tempDataStore==null){ if(tempDataStore==null){
String name=getTmpDataDirectory().getPath(); boolean result=true;
boolean empty=true;
try{ try{
log.info("About to delete any non-persistent messages that may have overflowed to disk ..."); File directory=getTmpDataDirectory();
StoreFactory.delete(name); if(directory.exists()&&directory.isDirectory()){
log.info("Successfully deleted temporary storage"); File[] files=directory.listFiles();
tempDataStore=StoreFactory.open(name,"rw"); if(files!=null&&files.length>0){
empty=false;
for(int i=0;i<files.length;i++){
File file=files[i];
if(!file.isDirectory()){
result&=file.delete();
}
}
}
}
if(!empty){
String str=result?"Successfully deleted":"Failed to delete";
log.info(str+" temporary storage");
}
tempDataStore=StoreFactory.open(getTmpDataDirectory().getPath(),"rw");
}catch(IOException e){ }catch(IOException e){
throw new RuntimeException(e); throw new RuntimeException(e);
} }