Skip to content
Snippets Groups Projects
Commit 1cc58181 authored by Bjoern Weissenfels's avatar Bjoern Weissenfels
Browse files

delete Observer and fixed NoSuchElementException

parent 23ac97d3
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ import java.util.Observable;
import java.util.Observer;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
......@@ -74,6 +75,11 @@ public class ChartBean implements Observer{
}
}
@PreDestroy
public void cleanup(){
this.dataBean.deleteObserver(this);
}
public void setDataBean(DataBean dataBean){
this.dataBean = dataBean;
}
......
......@@ -12,6 +12,7 @@ import java.util.Observer;
import java.util.Set;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
......@@ -89,6 +90,11 @@ public class CpuBean implements Observer{
}
}
@PreDestroy
public void cleanup(){
this.dataBean.deleteObserver(this);
}
// getter and setter
public void setDataBean(DataBean dataBean){
this.dataBean = dataBean;
......
......@@ -145,12 +145,11 @@ public class DataBean extends Observable{
}
// remove old records
if(!this.records.isEmpty()){
long currentTime = System.currentTimeMillis() * 1000000;
while((currentTime - this.recordStorageDuration) > this.records.getFirst().getOperationExecutionRecord().getLoggingTimestamp()){
while(!this.records.isEmpty() &&
(currentTime - this.recordStorageDuration) > this.records.getFirst().getOperationExecutionRecord().getLoggingTimestamp()){
this.records.removeFirst();
}
}
this.setChanged();
this.notifyObservers("oer");
......
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment