Skip to content

Commit

Permalink
Rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
maurever committed May 9, 2024
1 parent d3d27f0 commit bd887ed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 3 additions & 3 deletions h2o-core/src/main/java/water/AutoBuffer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1578,13 +1578,13 @@ public static byte[] javaSerializeWritePojo(Object o) {
}
}

public static Object javaSerializeReadPojo(byte [] bytes) {
public static Object javaSerializeReadBytes(byte [] bytes) {
try {
final ValidatingObjectInputStream ois = new ValidatingObjectInputStream(new ByteArrayInputStream(bytes));
// GH-16174 this method is used for HyperParameter serialization and allow execution of malicious code
// if the object type is not checked -> the acceptable objects are Integer, Number and String
// TODO: see what happens with other usage of this method -> edit acceptable classes based on the tests results
// TODO: find better way to defifne acceptable class
// TODO: find better way to define acceptable classes
ois.accept(Integer.class, Number.class, String.class,
water.exceptions.H2OIllegalArgumentException.class,
water.exceptions.H2OAbstractRuntimeException.class,
Expand Down Expand Up @@ -1657,7 +1657,7 @@ static String nameOfClass(byte[] bytes) {

@SuppressWarnings("unused") public Object getSer() {
byte[] ba = getA1();
return ba == null ? null : javaSerializeReadPojo(ba);
return ba == null ? null : javaSerializeReadBytes(ba);
}

@SuppressWarnings("unused") public <T> T getSer(Class<T> tc) {
Expand Down
4 changes: 1 addition & 3 deletions h2o-core/src/main/java/water/DTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import water.H2O.H2OCountedCompleter;
import water.util.DistributedException;

import java.io.*;

/** Objects which are passed and {@link #dinvoke} is remotely executed.<p>
* <p>
* Efficient serialization methods for subclasses will be automatically
Expand Down Expand Up @@ -42,7 +40,7 @@ public synchronized void setException(Throwable ex) {
}
/** The _ex field as a RuntimeException or null.
* @return The _ex field as a RuntimeException or null. */
public Throwable getDException() {return _ex == null?null:(Throwable)AutoBuffer.javaSerializeReadPojo(_ex);}
public Throwable getDException() {return _ex == null?null:(Throwable)AutoBuffer.javaSerializeReadBytes(_ex);}

// Track if the reply came via TCP - which means a timeout on ACKing the TCP
// result does NOT need to get the entire result again, just that the client
Expand Down
4 changes: 2 additions & 2 deletions h2o-core/src/main/java/water/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void fail(Throwable ex) {
private byte [] _ex;
public Throwable ex() {
if(_ex == null) return null;
return (Throwable)AutoBuffer.javaSerializeReadPojo(_ex);
return (Throwable)AutoBuffer.javaSerializeReadBytes(_ex);
}

/** Total expected work. */
Expand Down Expand Up @@ -438,7 +438,7 @@ public T get() {
bar.join(); // Block on the *barrier* task, which blocks until the fjtask on*Completion code runs completely
assert isStopped();
if (_ex!=null)
throw new RuntimeException((Throwable)AutoBuffer.javaSerializeReadPojo(_ex));
throw new RuntimeException((Throwable)AutoBuffer.javaSerializeReadBytes(_ex));
// Maybe null return, if the started fjtask does not actually produce a result at this Key
return _result==null ? null : _result.get();
}
Expand Down

0 comments on commit bd887ed

Please sign in to comment.