Skip to content

Commit

Permalink
fix serialize FileInputStream error
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jul 8, 2023
1 parent 49a6e88 commit ab6cd35
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/com/alibaba/fastjson2/util/BeanUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,10 @@ public abstract class BeanUtils {
1616814008855344660L,
2164749833121980361L,
3724195282986200606L,
3977020351318456359L, // sun.nio.ch.FileChannelImpl
4882459834864833642L,
7981148566008458638L,
8344106065386396833L
8344106065386396833L,
};

public static String[] getRecordFieldNames(Class<?> recordType) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.alibaba.fastjson2.issues_1500;

import com.alibaba.fastjson2.JSON;
import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class Issue1552 {
@Test
public void test() throws Exception {
File tempFile = File.createTempFile("tmp", "json");

Bean bean = new Bean();
bean.in = new FileInputStream(tempFile);

String str = JSON.toJSONString(bean);
assertNotNull(str);
}

public static class Bean {
public InputStream in;
}
}

0 comments on commit ab6cd35

Please sign in to comment.