summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/data
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-10-01 14:08:33 +0300
committerArtur Signell <artur@vaadin.com>2012-10-01 14:10:02 +0300
commit0e3b55601457da2d5bc9edb85d2de701409aeb5c (patch)
tree60de7683e756592418449fab80cb8fa52c9a60c1 /server/src/com/vaadin/data
parent4a9daa9edda206840aef12732606608587ce05ac (diff)
downloadvaadin-framework-0e3b55601457da2d5bc9edb85d2de701409aeb5c.tar.gz
vaadin-framework-0e3b55601457da2d5bc9edb85d2de701409aeb5c.zip
Avoid throwing exceptions from toString, log message instead (#9804)
Change-Id: Ia2f8504a0fe75ab3a7c4746d533e5fd012e2a69c
Diffstat (limited to 'server/src/com/vaadin/data')
-rw-r--r--server/src/com/vaadin/data/util/AbstractProperty.java18
-rw-r--r--server/src/com/vaadin/data/util/IndexedContainer.java18
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java18
3 files changed, 47 insertions, 7 deletions
diff --git a/server/src/com/vaadin/data/util/AbstractProperty.java b/server/src/com/vaadin/data/util/AbstractProperty.java
index 76d47039d0..aefe00ad32 100644
--- a/server/src/com/vaadin/data/util/AbstractProperty.java
+++ b/server/src/com/vaadin/data/util/AbstractProperty.java
@@ -18,6 +18,7 @@ package com.vaadin.data.util;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
+import java.util.logging.Logger;
import com.vaadin.data.Property;
@@ -78,9 +79,17 @@ public abstract class AbstractProperty<T> implements Property<T>,
@Deprecated
@Override
public String toString() {
- throw new UnsupportedOperationException(
- "Use Property.getValue() instead of " + getClass()
- + ".toString()");
+ getLogger()
+ .warning(
+ "You are using Property.toString() instead of getValue() to get the value for a "
+ + getClass().getSimpleName()
+ + ". This will not be supported starting from Vaadin 7.1 "
+ + "(your debugger might call toString() and cause this message to appear).");
+ T v = getValue();
+ if (v == null) {
+ return null;
+ }
+ return v.toString();
}
/* Events */
@@ -277,4 +286,7 @@ public abstract class AbstractProperty<T> implements Property<T>,
return Collections.EMPTY_LIST;
}
+ private static Logger getLogger() {
+ return Logger.getLogger(AbstractProperty.class.getName());
+ }
}
diff --git a/server/src/com/vaadin/data/util/IndexedContainer.java b/server/src/com/vaadin/data/util/IndexedContainer.java
index e957d958a9..7273b28b66 100644
--- a/server/src/com/vaadin/data/util/IndexedContainer.java
+++ b/server/src/com/vaadin/data/util/IndexedContainer.java
@@ -28,6 +28,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import com.vaadin.data.Container;
import com.vaadin.data.Item;
@@ -961,8 +962,21 @@ public class IndexedContainer extends
@Deprecated
@Override
public String toString() {
- throw new UnsupportedOperationException(
- "Use Property.getValue() instead of IndexedContainerProperty.toString()");
+ getLogger()
+ .warning(
+ "You are using IndexedContainerProperty.toString() instead of getValue() to get the value for a "
+ + getClass().getSimpleName()
+ + ". This will not be supported starting from Vaadin 7.1 "
+ + "(your debugger might call toString() and cause this message to appear).");
+ Object v = getValue();
+ if (v == null) {
+ return null;
+ }
+ return v.toString();
+ }
+
+ private Logger getLogger() {
+ return Logger.getLogger(IndexedContainerProperty.class.getName());
}
/**
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
index 6e5ba0dc57..bd6b1a75bf 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/ColumnProperty.java
@@ -18,6 +18,7 @@ package com.vaadin.data.util.sqlcontainer;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.logging.Logger;
import com.vaadin.data.Property;
import com.vaadin.data.util.converter.Converter.ConversionException;
@@ -261,8 +262,21 @@ final public class ColumnProperty implements Property {
@Deprecated
@Override
public String toString() {
- throw new UnsupportedOperationException(
- "Use ColumnProperty.getValue() instead of ColumnProperty.toString()");
+ getLogger()
+ .warning(
+ "You are using ColumnProperty.toString() instead of getValue() to get the value for a "
+ + getClass().getSimpleName()
+ + ". This will not be supported starting from Vaadin 7.1 "
+ + "(your debugger might call toString() and cause this message to appear).");
+ Object v = getValue();
+ if (v == null) {
+ return null;
+ }
+ return v.toString();
+ }
+
+ private static Logger getLogger() {
+ return Logger.getLogger(ColumnProperty.class.getName());
}
public void setOwner(RowItem owner) {