Skip to content

Commit

Permalink
#3033 Fixed HttpMessageNotWritableException:
Browse files Browse the repository at this point in the history
- corrected initialize Application with empty database: SystemSettingsService.getCustomCss();
- corrected try-catch Exception: pointEventDetectorDAO.insert;
- corrected toString for BatchWriteBehind;
  • Loading branch information
Limraj committed Oct 21, 2024
1 parent 55cd3f5 commit 8d30fb9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/org/scada_lts/mango/service/DataPointService.java
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ public void saveEventDetectors(DataPointVO dataPoint) {
for (PointEventDetectorVO pointEventDetector: dataPoint.getEventDetectors()) {
try {
pointEventDetectorDAO.insert(dataPoint.getId(), pointEventDetector);
} catch (DuplicateKeyException e) {
} catch (Exception e) {
pointEventDetectorDAO.update(dataPoint.getId(), pointEventDetector);
}
}
Expand Down
8 changes: 7 additions & 1 deletion src/org/scada_lts/mango/service/PointValueService.java
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,16 @@ static void add(BatchWriteBehindEntry e) {
}
}
}

private int instancesSize;
private int entriesSize;

public BatchWriteBehind() {}

@Override
public void work() {
try {
this.instancesSize = instances.size();
BatchWriteBehindEntry[] inserts;
while (true) {
synchronized (ENTRIES) {
Expand All @@ -558,6 +563,7 @@ public void work() {

inserts = new BatchWriteBehindEntry[ENTRIES.size() < MAX_ROWS ? ENTRIES
.size() : MAX_ROWS];
this.entriesSize = inserts.length;
ENTRIES.pop(inserts);
ENTRIES_MONITOR.setValue(ENTRIES.size());
}
Expand Down Expand Up @@ -617,7 +623,7 @@ public WorkItemPriority getPriorityType() {

@Override
public String toString() {
return "BatchWriteBehind{instances size: " + instances.size() + '}';
return "BatchWriteBehind{current instances size: " + INSTANCES_MONITOR.getValue() + ", current entries size: " + ENTRIES_MONITOR.getValue() + ", instances size: " + this.instancesSize + ", entries size: " + this.entriesSize + '}';
}

@Override
Expand Down
11 changes: 9 additions & 2 deletions src/org/scada_lts/mango/service/SystemSettingsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.serotonin.mango.rt.event.type.AuditEventType;
import com.serotonin.mango.rt.event.type.SystemEventType;
import com.serotonin.mango.rt.maint.DataPurge;
import com.serotonin.mango.util.LoggingUtils;
import com.serotonin.mango.vo.User;
import com.serotonin.mango.vo.bean.PointHistoryCount;
import com.serotonin.mango.vo.event.EventTypeVO;
Expand Down Expand Up @@ -522,8 +523,14 @@ private static Map<String, String> deserializeMap(String json) {
}

public CssStyle getCustomCss() {
String content = SystemSettingsDAO.getValue(SystemSettingsDAO.CUSTOM_CSS_CONTENT);
return new CssStyle(content);
String defaultContent = SystemSettingsUtils.getCustomCssContent();
try {
String content = SystemSettingsDAO.getValue(SystemSettingsDAO.CUSTOM_CSS_CONTENT);
return new CssStyle(content);
} catch (Exception ex) {
LOG.error(LoggingUtils.exceptionInfo(ex));
return new CssStyle(defaultContent);
}
}

public void saveCustomCss(CssStyle cssStyle) {
Expand Down

0 comments on commit 8d30fb9

Please sign in to comment.