Skip to content

Commit

Permalink
Third part of #661: remove IOException from factories too. Close to f…
Browse files Browse the repository at this point in the history
…ull eradication for core
  • Loading branch information
cowtowncoder committed Jan 12, 2021
1 parent cde9443 commit e9bf9b6
Show file tree
Hide file tree
Showing 30 changed files with 584 additions and 510 deletions.
15 changes: 4 additions & 11 deletions src/main/java/com/fasterxml/jackson/core/JsonGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.fasterxml.jackson.core.type.WritableTypeId;
import com.fasterxml.jackson.core.type.WritableTypeId.Inclusion;
import com.fasterxml.jackson.core.util.JacksonFeatureSet;
import com.fasterxml.jackson.core.util.VersionUtil;

import static com.fasterxml.jackson.core.JsonTokenId.*;

Expand Down Expand Up @@ -679,10 +678,7 @@ public void writeArray(String[] array, int offset, int length) throws JacksonExc
* @throws JsonGenerationException for problems in encoding token stream
* (including the case where {@code reader} does not provide enough content)
*/
public void writeString(Reader reader, int len) throws JacksonException {
// Let's implement this as "unsupported" to make it easier to add new parser impls
_reportUnsupportedOperation();
}
public abstract void writeString(Reader reader, int len) throws JacksonException;

/**
* Method for outputting a String value. Depending on context
Expand Down Expand Up @@ -1752,6 +1748,9 @@ public void writeOmittedField(String fieldName) throws JacksonException { }
/*
/**********************************************************************
/* Public API, copy-through methods
/*
/* NOTE: need to remain here for `JsonGeneratorDelegate` to call
/* (or refactor to have "JsonGeneratorMinimalBase" or such)
/**********************************************************************
*/

Expand Down Expand Up @@ -2057,12 +2056,6 @@ protected <T> T _reportError(String msg) throws JsonGenerationException {
throw new JsonGenerationException(msg, this);
}

protected void _throwInternal() { VersionUtil.throwInternal(); }

protected <T> T _reportUnsupportedOperation() {
throw new UnsupportedOperationException("Operation not supported by generator of type "+getClass().getName());
}

protected final void _verifyOffsets(int arrayLength, int offset, int length)
{
if ((offset < 0) || (offset + length) > arrayLength) {
Expand Down
14 changes: 1 addition & 13 deletions src/main/java/com/fasterxml/jackson/core/JsonParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -905,19 +905,7 @@ public Boolean nextBooleanValue() throws JacksonException {
* @throws WrappedIOException for low-level read issues, or failed write using {@link Writer}
* @throws com.fasterxml.jackson.core.exc.StreamReadException for decoding problems
*/
public int getText(Writer writer) throws JacksonException, UnsupportedOperationException
{
String str = getText();
if (str == null) {
return 0;
}
try {
writer.write(str);
} catch (IOException e) {
throw WrappedIOException.construct(e);
}
return str.length();
}
public abstract int getText(Writer writer) throws JacksonException;

/**
* Method similar to {@link #getText}, but that will return
Expand Down
11 changes: 5 additions & 6 deletions src/main/java/com/fasterxml/jackson/core/ObjectReadContext.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.fasterxml.jackson.core;

import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;

Expand Down Expand Up @@ -35,23 +34,23 @@ public static ObjectReadContext empty() {

// // // Parser construction

default JsonParser createParser(InputStream in) throws IOException {
default JsonParser createParser(InputStream in) throws JacksonException {
return getParserFactory().createParser(this, in);
}

default JsonParser createParser(Reader r) throws IOException {
default JsonParser createParser(Reader r) throws JacksonException {
return getParserFactory().createParser(this, r);
}

default JsonParser createParser(String content) throws IOException {
default JsonParser createParser(String content) throws JacksonException {
return getParserFactory().createParser(this, content);
}

default JsonParser createParser(byte[] content) throws IOException {
default JsonParser createParser(byte[] content) throws JacksonException {
return getParserFactory().createParser(this, content);
}

default JsonParser createParser(byte[] content, int offset, int length) throws IOException {
default JsonParser createParser(byte[] content, int offset, int length) throws JacksonException {
return getParserFactory().createParser(this, content, offset, length);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.fasterxml.jackson.core;

import java.io.IOException;
import java.io.OutputStream;
import java.io.Writer;

Expand Down Expand Up @@ -52,15 +51,15 @@ public static ObjectWriteContext empty() {
// // // Generator construction: limited to targets that make sense for embedding
// // // purposes (like "JSON in JSON" etc)

default JsonGenerator createGenerator(OutputStream out) throws IOException {
default JsonGenerator createGenerator(OutputStream out) throws JacksonException {
return getGeneratorFactory().createGenerator(this, out);
}

default JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws IOException {
default JsonGenerator createGenerator(OutputStream out, JsonEncoding enc) throws JacksonException {
return getGeneratorFactory().createGenerator(this, out, enc);
}

default JsonGenerator createGenerator(Writer w) throws IOException {
default JsonGenerator createGenerator(Writer w) throws JacksonException {
return getGeneratorFactory().createGenerator(this, w);
}

Expand Down
Loading

0 comments on commit e9bf9b6

Please sign in to comment.