Skip to content

Commit

Permalink
Fix unchecked warning introduced in 5559ba1
Browse files Browse the repository at this point in the history
Factor the work of lax() into a static method on AdjustingJAXPParser
but push the instance methods down to the concrete subclasses, which
can return 'this' with the expected type and no unchecked warning.
  • Loading branch information
jcflack committed Sep 1, 2023
1 parent 83f5f5a commit df912da
Showing 1 changed file with 38 additions and 6 deletions.
44 changes: 38 additions & 6 deletions pljava/src/main/java/org/postgresql/pljava/jdbc/SQLXMLImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -4203,16 +4203,20 @@ protected Exception exceptions()
return e;
}

@Override
public T lax(boolean discard)
/**
* Common factor of subclass {@link #lax() lax()} instance methods.
*<p>
* The work is done here, but the instance methods are implemented
* per-subclass to avoid unchecked casting of 'this'.
*/
protected static void lax(AdjustingJAXPParser o, boolean discard)
{
if ( null != m_quiet )
if ( null != o.m_quiet )
{
if ( ! discard )
addSignaling(m_quiet);
m_quiet = null;
o.addSignaling(o.m_quiet);
o.m_quiet = null;
}
return (T)this;
}

@Override
Expand Down Expand Up @@ -5093,6 +5097,13 @@ public SAXSource get() throws SQLException
return ss;
}

@Override
public AdjustingSAXSource lax(boolean discard)
{
lax(this, discard);
return this;
}

@Override
public AdjustingSAXSource defaults()
{
Expand Down Expand Up @@ -5215,6 +5226,13 @@ public SAXResult get() throws SQLException
return sr;
}

@Override
public AdjustingSAXResult lax(boolean discard)
{
lax(this, discard);
return this;
}

@Override
public AdjustingSAXResult xIncludeAware(boolean v)
{
Expand Down Expand Up @@ -5324,6 +5342,13 @@ public StAXSource get() throws SQLException
return ss;
}

@Override
public AdjustingStAXSource lax(boolean discard)
{
lax(this, discard);
return this;
}

@Override
public AdjustingStAXSource allowDTD(boolean v) {
return setFirstSupportedFeature( v, XMLInputFactory.SUPPORT_DTD);
Expand Down Expand Up @@ -5457,6 +5482,13 @@ public DOMSource get() throws SQLException
return ds;
}

@Override
public AdjustingDOMSource lax(boolean discard)
{
lax(this, discard);
return this;
}

@Override
public AdjustingDOMSource xIncludeAware(boolean v)
{
Expand Down

0 comments on commit df912da

Please sign in to comment.