Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add hessian codec for rpc Serialization #1983

Merged
merged 20 commits into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bf35f44
add hessian codec for rpc Serialization
lovepoem Dec 3, 2019
607516e
add hessian codec for rpc Serialization
lovepoem Dec 3, 2019
29b15fc
Merge branch 'develop' into hessian_serialization
lovepoem Dec 3, 2019
85aa884
add hessian codec for rpc Serialization
lovepoem Dec 3, 2019
96d58aa
Merge branch 'hessian_serialization' of http://github.com/lovepoem/se…
lovepoem Dec 3, 2019
59ab3aa
Merge branch 'develop' into hessian_serialization
lovepoem Dec 3, 2019
164ee01
Merge remote-tracking branch 'seata_rem/develop' into hessian_seriali…
lovepoem Dec 3, 2019
13f5517
Merge branch 'hessian_serialization' of http://github.com/lovepoem/se…
lovepoem Dec 3, 2019
d4e8d73
Merge remote-tracking branch 'seata_rem/develop' into hessian_seriali…
lovepoem Dec 4, 2019
249ea8f
review update
lovepoem Dec 6, 2019
739b82d
format log
lovepoem Dec 6, 2019
eed6afd
Merge branch 'develop' into hessian_serialization
lovepoem Dec 6, 2019
84e2074
Merge branch 'develop' into hessian_serialization
lovepoem Dec 8, 2019
0154a9e
Merge remote-tracking branch 'seata_rem/develop' into hessian_seriali…
lovepoem Dec 8, 2019
740445e
Merge branch 'hessian_serialization' of http://github.com/lovepoem/se…
lovepoem Dec 8, 2019
0954d72
Merge branch 'develop' into hessian_serialization
lovepoem Dec 9, 2019
0c6502f
Merge remote-tracking branch 'seata_rem/develop' into hessian_seriali…
lovepoem Dec 9, 2019
b4013e6
update
lovepoem Dec 9, 2019
bd54320
Merge branch 'develop' into hessian_serialization
jsbxyyx Dec 9, 2019
6c139e4
Merge branch 'develop' into hessian_serialization
xingfudeshi Dec 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
review update
  • Loading branch information
lovepoem committed Dec 6, 2019
commit 249ea8f2d8d647d581aee645029d27b45e310172
17 changes: 16 additions & 1 deletion codec/seata-codec-hessian/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
lovepoem marked this conversation as resolved.
Show resolved Hide resolved
<!--
~ Copyright 1999-2019 Seata.io Group.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
Expand All @@ -18,7 +33,7 @@
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-core</artifactId>
<version>1.0.0-SNAPSHOT</version>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.caucho.hessian.io.Hessian2Input;
import com.caucho.hessian.io.Hessian2Output;
import com.caucho.hessian.io.HessianProtocolException;
import com.caucho.hessian.io.Serializer;
import com.caucho.hessian.io.SerializerFactory;
import io.seata.common.loader.LoadLevel;
Expand All @@ -34,7 +33,7 @@
*/
@LoadLevel(name = "HESSIAN")
public class HessianCodec implements Codec {
private final Logger logger = LoggerFactory.getLogger(HessianCodec.class);
private static final Logger LOGGER = LoggerFactory.getLogger(HessianCodec.class);

@Override
public <T> byte[] encode(T t) {
Expand All @@ -47,32 +46,22 @@ public <T> byte[] encode(T t) {
serializer.writeObject(t, output);
output.close();
stream = baos.toByteArray();
} catch (HessianProtocolException e) {
logger.error("Hessian encode error", e);
} catch (IOException e) {
logger.error("Hessian encode error", e);
LOGGER.error("Hessian encode error", e);
lovepoem marked this conversation as resolved.
Show resolved Hide resolved
}
return stream;
}

@Override
public <T> T decode(byte[] bytes) {
Hessian2Input input = null;
try {
ByteArrayInputStream is = new ByteArrayInputStream(bytes);
input = new Hessian2Input(is);
try {
return (T) input.readObject();
} catch (IOException e) {
logger.error("Hessian decode error", e);
}
} finally {
try {
input.close();
} catch (IOException e) {
logger.error("Hessian decode error", e);
}
T obj = null;
try (ByteArrayInputStream is = new ByteArrayInputStream(bytes);) {
Hessian2Input input = new Hessian2Input(is);
obj = (T) input.readObject();
input.close();
} catch (IOException e) {
LOGGER.error("Hessian decode error", e);
lovepoem marked this conversation as resolved.
Show resolved Hide resolved
}
return null;
return obj;
}
}