Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions core/src/main/java/com/qq/tars/protocol/util/TarsHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,9 @@ public static boolean isRoutekey(Annotation[] annotations) {

public static boolean isStruct(Class<?> clazz) {
boolean isStruct = clazz.isAnnotationPresent(TarsStruct.class);
if (isStruct) {
getStructInfo(clazz);
}
// if (isStruct) {
// getStructInfo(clazz);
// }
return isStruct;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// **********************************************************************
// This file was generated by a TARS parser!
// TARS version 1.0.1.
// **********************************************************************

package com.qq.tars.quickstart.server.testapp;

import com.qq.tars.protocol.tars.TarsInputStream;
import com.qq.tars.protocol.tars.TarsOutputStream;
import com.qq.tars.protocol.tars.annotation.TarsStruct;
import com.qq.tars.protocol.tars.annotation.TarsStructProperty;
import com.qq.tars.protocol.util.TarsUtil;

@TarsStruct
public class TestRecursive {

@TarsStructProperty(order = 0, isRequire = false)
public int value = 0;
@TarsStructProperty(order = 1, isRequire = false)
public TestRecursive testRecursive = null;

public int getValue() {
return value;
}

public void setValue(int value) {
this.value = value;
}

public TestRecursive getTestRecursive() {
return testRecursive;
}

public void setTestRecursive(TestRecursive testRecursive) {
this.testRecursive = testRecursive;
}

public TestRecursive() {
}

public TestRecursive(int value, TestRecursive testRecursive) {
this.value = value;
this.testRecursive = testRecursive;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + TarsUtil.hashCode(value);
result = prime * result + TarsUtil.hashCode(testRecursive);
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TestRecursive)) {
return false;
}
TestRecursive other = (TestRecursive) obj;
return (
TarsUtil.equals(value, other.value) &&
TarsUtil.equals(testRecursive, other.testRecursive)
);
}

public void writeTo(TarsOutputStream _os) {
_os.write(value, 0);
if (null != testRecursive) {
_os.write(testRecursive, 1);
}
}

static TestRecursive cache_testRecursive;
static {
cache_testRecursive = new TestRecursive();
}

public void readFrom(TarsInputStream _is) {
this.value = _is.read(value, 0, false);
this.testRecursive = (TestRecursive) _is.read(cache_testRecursive, 1, false);
}

}
27 changes: 27 additions & 0 deletions core/src/test/java/com/tencent/tars/TestTarsRecursive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.tencent.tars;

import com.qq.tars.protocol.tars.TarsOutputStream;
import com.qq.tars.quickstart.server.testapp.TestRecursive;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;

public class TestTarsRecursive {

@Test
public void testRecursiveReproduce() {

TestRecursive testRecursive = new TestRecursive();
testRecursive.value = 1;
TestRecursive testRecursive2 = new TestRecursive();
testRecursive2.value =2;
testRecursive.testRecursive = testRecursive2;
// System.out.println(testRecursive.testRecursive.getValue());

TarsOutputStream tafOutputStream = new TarsOutputStream();
System.out.println("begin to write.");
testRecursive.writeTo(tafOutputStream);
System.out.println("write end.");

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
// **********************************************************************
// This file was generated by a TARS parser!
// TARS version 1.0.1.
// **********************************************************************

package com.qq.tars.quickstart.server.testapp;

import com.qq.tars.protocol.util.*;
import com.qq.tars.protocol.annotation.*;
import com.qq.tars.protocol.tars.*;
import com.qq.tars.protocol.tars.annotation.*;

@TarsStruct
public class TestRecursive {

@TarsStructProperty(order = 0, isRequire = false)
public int value = 0;
@TarsStructProperty(order = 1, isRequire = false)
public TestRecursive testRecursive = null;

public int getValue() {
return value;
}

public void setValue(int value) {
this.value = value;
}

public TestRecursive getTestRecursive() {
return testRecursive;
}

public void setTestRecursive(TestRecursive testRecursive) {
this.testRecursive = testRecursive;
}

public TestRecursive() {
}

public TestRecursive(int value, TestRecursive testRecursive) {
this.value = value;
this.testRecursive = testRecursive;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + TarsUtil.hashCode(value);
result = prime * result + TarsUtil.hashCode(testRecursive);
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TestRecursive)) {
return false;
}
TestRecursive other = (TestRecursive) obj;
return (
TarsUtil.equals(value, other.value) &&
TarsUtil.equals(testRecursive, other.testRecursive)
);
}

public void writeTo(TarsOutputStream _os) {
_os.write(value, 0);
if (null != testRecursive) {
_os.write(testRecursive, 1);
}
}

static TestRecursive cache_testRecursive;
static {
cache_testRecursive = new TestRecursive();
}

public void readFrom(TarsInputStream _is) {
this.value = _is.read(value, 0, false);
this.testRecursive = (TestRecursive) _is.read(cache_testRecursive, 1, false);
}

}
24 changes: 24 additions & 0 deletions examples/quickstart-server/src/main/resources/TestRecursive.tars
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Tencent is pleased to support the open source community by making Tars available.
*
* Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* 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.
*/

module TestApp
{
struct TestRecursive
{
0 optional int value;
1 optional TestRecursive testRecursive;
};
};