Skip to content

Commit

Permalink
chore: log a warn when Lyo OGM fails to invoke a setter (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
berezovskyi committed Nov 16, 2023
1 parent 330c45d commit 73a78a0
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.logging.Logger;

import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
Expand Down Expand Up @@ -82,6 +81,8 @@
import org.eclipse.lyo.oslc4j.core.model.ResponseInfo;
import org.eclipse.lyo.oslc4j.core.model.TypeFactory;
import org.eclipse.lyo.oslc4j.core.model.XMLLiteral;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Use JSON-LD support in Jena provider.
Expand Down Expand Up @@ -141,7 +142,7 @@ public final class JsonHelper
*/
public static final String OSLC4J_READ_SPECIAL_NUMS = "org.eclipse.lyo.oslc4j.readSpecialNumberValues";

private static final Logger logger = Logger.getLogger(JsonHelper.class.getName());
private static final Logger logger = LoggerFactory.getLogger(JsonHelper.class.getName());

private JsonHelper()
{
Expand Down Expand Up @@ -936,7 +937,7 @@ else if (properties instanceof NestedWildcardProperties)

if (value == null && ! onlyNested)
{
logger.warning("Could not add extended property " + extendedProperty.getKey() + " for resource " + extendedResource.getAbout());
logger.warn("Could not add extended property " + extendedProperty.getKey() + " for resource " + extendedResource.getAbout());
}
else
{
Expand Down Expand Up @@ -1615,7 +1616,7 @@ else if (bean instanceof IReifiedResource)
{
if (!JSON_PROPERTY_PREFIXES.equals(prefixedName))
{
logger.warning("Ignored JSON property '" +
logger.warn("Ignored JSON property '" +
prefixedName +
"'.");
}
Expand Down Expand Up @@ -1656,7 +1657,7 @@ else if (RDF_TYPE_URI.equals(propertyDefinition))
{
if (extendedProperties == null)
{
logger.fine("Set method not found for object type: " +
logger.debug("Set method not found for object type: " +
beanClass.getName() +
", propertyDefinition: " +
propertyDefinition);
Expand Down Expand Up @@ -1717,9 +1718,15 @@ else if (Collection.class.isAssignableFrom(setMethodComponentParameterClass))

if (parameter != null)
{
setMethod.invoke(bean,
new Object[] {parameter});
}
try {
setMethod.invoke(bean,
new Object[] {parameter});
} catch (IllegalAccessException | IllegalArgumentException |
InvocationTargetException e) {
logger.warn("Failed to set property {}='{}' via '{}'", prefixedName, parameter, setMethod.getName());
throw e;
}
}
}
}
}
Expand Down Expand Up @@ -2146,7 +2153,7 @@ else if (jsonValue == null)
{
if (readSpecialNumberValues())
{
logger.warning("Null double value treated as NaN.");
logger.warn("Null double value treated as NaN.");
return Double.NaN;
}
else
Expand All @@ -2160,7 +2167,7 @@ else if (jsonValue == null)
{
if (readSpecialNumberValues())
{
logger.warning("Null float value treated as NaN.");
logger.warn("Null float value treated as NaN.");
return Float.NaN;
}
else
Expand Down

0 comments on commit 73a78a0

Please sign in to comment.