Java Code Examples for com.alibaba.dubbo.common.utils.StringUtils#toString()

The following examples show how to use com.alibaba.dubbo.common.utils.StringUtils#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Builder.java    From dubbo3 with Apache License 2.0 6 votes vote down vote up
@Override
public Serializable parseFrom(GenericObjectInput in) throws IOException {
    byte b = in.read0();
    if (b == OBJECT_NULL)
        return null;
    if (b != OBJECT_STREAM)
        throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + ".");

    UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt()));
    CompactedObjectInputStream ois = new CompactedObjectInputStream(bis);
    try {
        return (Serializable) ois.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString(e));
    }
}
 
Example 2
Source File: ExchangeCodec.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
protected Object decodeResponseData(ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 3
Source File: DeprecatedExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object decodeEventData(Channel channel, ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 4
Source File: GrizzlyHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public NextAction handleWrite(FilterChainContext ctx) throws IOException {
    Connection<?> connection = ctx.getConnection();
    GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
    try {
        handler.sent(channel, ctx.getMessage());
    } catch (RemotingException e) {
        throw new IOException(StringUtils.toString(e));
    } finally {
        GrizzlyChannel.removeChannelIfDisconnectd(connection);
    }
    return ctx.getInvokeAction();
}
 
Example 5
Source File: ExchangeCodec.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
protected Object decodeEventData(Channel channel, ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 6
Source File: DeprecatedExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object decodeRequestData(ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 7
Source File: DeprecatedExchangeCodec.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
protected Object decodeResponseData(ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 8
Source File: ExchangeCodec.java    From dubbo3 with Apache License 2.0 5 votes vote down vote up
@Deprecated
protected Object decodeHeartbeatData(ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 9
Source File: GrizzlyHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public NextAction handleClose(FilterChainContext ctx) throws IOException {
    Connection<?> connection = ctx.getConnection();
    GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
    try {
        handler.disconnected(channel);
    } catch (RemotingException e) {
        throw new IOException(StringUtils.toString(e));
    } finally {
        GrizzlyChannel.removeChannelIfDisconnectd(connection);
    }
    return ctx.getInvokeAction();
}
 
Example 10
Source File: Builder.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public Serializable parseFrom(GenericObjectInput in) throws IOException
{
	byte b = in.read0();
	if( b == OBJECT_NULL )
		return null;
	if( b != OBJECT_STREAM )
		throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + ".");

	UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt()));
	CompactedObjectInputStream ois = new CompactedObjectInputStream(bis);
	try{ return (Serializable)ois.readObject(); }
	catch(ClassNotFoundException e){ throw new IOException(StringUtils.toString(e)); }
}
 
Example 11
Source File: ExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
protected Object decodeRequestData(ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 12
Source File: DeprecatedExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Deprecated
protected Object decodeHeartbeatData(Channel channel, ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 13
Source File: Request.java    From dubbox-hystrix with Apache License 2.0 5 votes vote down vote up
private static String safeToString(Object data) {
    if (data == null) return null;
    String dataStr;
    try {
        dataStr = data.toString();
    } catch (Throwable e) {
        dataStr = "<Fail toString of " + data.getClass() + ", cause: " +
                StringUtils.toString(e) + ">";
    }
    return dataStr;
}
 
Example 14
Source File: GrizzlyHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public NextAction handleWrite(FilterChainContext ctx) throws IOException {
    Connection<?> connection = ctx.getConnection();
    GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
    try {
        handler.sent(channel, ctx.getMessage());
    } catch (RemotingException e) {
        throw new IOException(StringUtils.toString(e));
    } finally {
        GrizzlyChannel.removeChannelIfDisconnectd(connection);
    }
    return ctx.getInvokeAction();
}
 
Example 15
Source File: GrizzlyHandler.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public NextAction handleRead(FilterChainContext ctx) throws IOException {
    Connection<?> connection = ctx.getConnection();
    GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
    try {
        handler.received(channel, ctx.getMessage());
    } catch (RemotingException e) {
        throw new IOException(StringUtils.toString(e));
    } finally {
        GrizzlyChannel.removeChannelIfDisconnectd(connection);
    }
    return ctx.getInvokeAction();
}
 
Example 16
Source File: Builder.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Override
public Serializable parseFrom(GenericObjectInput in) throws IOException
{
	byte b = in.read0();
	if( b == OBJECT_NULL )
		return null;
	if( b != OBJECT_STREAM )
		throw new IOException("Input format error, expect OBJECT_NULL|OBJECT_STREAM, get " + b + ".");

	UnsafeByteArrayInputStream bis = new UnsafeByteArrayInputStream(in.read0(in.readUInt()));
	CompactedObjectInputStream ois = new CompactedObjectInputStream(bis);
	try{ return (Serializable)ois.readObject(); }
	catch(ClassNotFoundException e){ throw new IOException(StringUtils.toString(e)); }
}
 
Example 17
Source File: DeprecatedExchangeCodec.java    From dubbox with Apache License 2.0 5 votes vote down vote up
@Deprecated
protected Object decodeHeartbeatData(ObjectInput in) throws IOException {
    try {
        return in.readObject();
    } catch (ClassNotFoundException e) {
        throw new IOException(StringUtils.toString("Read object failed.", e));
    }
}
 
Example 18
Source File: GrizzlyHandler.java    From dubbo-2.6.5 with Apache License 2.0 5 votes vote down vote up
@Override
public NextAction handleConnect(FilterChainContext ctx) throws IOException {
    Connection<?> connection = ctx.getConnection();
    GrizzlyChannel channel = GrizzlyChannel.getOrAddChannel(connection, url, handler);
    try {
        handler.connected(channel);
    } catch (RemotingException e) {
        throw new IOException(StringUtils.toString(e));
    } finally {
        GrizzlyChannel.removeChannelIfDisconnected(connection);
    }
    return ctx.getInvokeAction();
}
 
Example 19
Source File: GenericException.java    From dubbox with Apache License 2.0 4 votes vote down vote up
public GenericException(Throwable cause) {
	super(StringUtils.toString(cause));
	this.exceptionClass = cause.getClass().getName();
	this.exceptionMessage = cause.getMessage();
}
 
Example 20
Source File: GenericException.java    From dubbox-hystrix with Apache License 2.0 4 votes vote down vote up
public GenericException(Throwable cause) {
	super(StringUtils.toString(cause));
	this.exceptionClass = cause.getClass().getName();
	this.exceptionMessage = cause.getMessage();
}