Code Review
/
netconf.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Remove the option to deliver streams over WebSockets
[netconf.git]
/
netconf
/
netconf-netty-util
/
src
/
main
/
java
/
org
/
opendaylight
/
netconf
/
nettyutil
/
handler
/
NetconfEXICodec.java
diff --git
a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfEXICodec.java
b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfEXICodec.java
index 383e8b7d50d2eb87e3ffeb5cbfe9e8b5d9703991..415afe3d0abad056a01a6b6301ec05f972177025 100644
(file)
--- a/
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfEXICodec.java
+++ b/
netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/NetconfEXICodec.java
@@
-5,33
+5,26
@@
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.netconf.nettyutil.handler;
package org.opendaylight.netconf.nettyutil.handler;
-import com.google.common.base.Preconditions;
+import static java.util.Objects.requireNonNull;
+
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
-import com.siemens.ct.exi.EXIFactory;
-import com.siemens.ct.exi.api.sax.SAXEncoder;
-import com.siemens.ct.exi.api.sax.SAXFactory;
-import com.siemens.ct.exi.exceptions.EXIException;
import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
import org.opendaylight.netconf.nettyutil.handler.exi.EXIParameters;
+import org.opendaylight.netconf.shaded.exificient.core.EXIFactory;
+import org.opendaylight.netconf.shaded.exificient.core.exceptions.EXIException;
+import org.opendaylight.netconf.shaded.exificient.main.api.sax.SAXEncoder;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
import org.xml.sax.EntityResolver;
import org.xml.sax.InputSource;
-import org.xml.sax.XMLReader;
public final class NetconfEXICodec {
/**
* OpenEXI does not allow us to directly prevent resolution of external entities. In order
* to prevent XXE attacks, we reuse a single no-op entity resolver.
*/
public final class NetconfEXICodec {
/**
* OpenEXI does not allow us to directly prevent resolution of external entities. In order
* to prevent XXE attacks, we reuse a single no-op entity resolver.
*/
- private static final EntityResolver ENTITY_RESOLVER = new EntityResolver() {
- @Override
- public InputSource resolveEntity(final String publicId, final String systemId) {
- return new InputSource();
- }
- };
+ private static final EntityResolver ENTITY_RESOLVER = (publicId, systemId) -> new InputSource();
/**
* Since we have a limited number of options we can have, instantiating a weak cache
/**
* Since we have a limited number of options we can have, instantiating a weak cache
@@
-45,24
+38,23
@@
public final class NetconfEXICodec {
}
});
}
});
- private final SAXFactory exiFactory;
+ private final
ThreadLocal
SAXFactory exiFactory;
private NetconfEXICodec(final EXIFactory exiFactory) {
private NetconfEXICodec(final EXIFactory exiFactory) {
- this.exiFactory = new
SAXFactory(Preconditions.checkNot
Null(exiFactory));
+ this.exiFactory = new
ThreadLocalSAXFactory(requireNon
Null(exiFactory));
}
public static NetconfEXICodec forParameters(final EXIParameters parameters) {
return CODECS.getUnchecked(parameters);
}
}
public static NetconfEXICodec forParameters(final EXIParameters parameters) {
return CODECS.getUnchecked(parameters);
}
-
XMLRea
der getReader() throws EXIException {
- final
XMLRea
der reader = exiFactory.createEXIReader();
+
ThreadLocalSAXDeco
der getReader() throws EXIException {
+ final
ThreadLocalSAXDeco
der reader = exiFactory.createEXIReader();
reader.setEntityResolver(ENTITY_RESOLVER);
return reader;
}
SAXEncoder getWriter() throws EXIException {
reader.setEntityResolver(ENTITY_RESOLVER);
return reader;
}
SAXEncoder getWriter() throws EXIException {
- final SAXEncoder writer = exiFactory.createEXIWriter();
- return writer;
+ return exiFactory.createEXIWriter();
}
}
}
}