{"action":"created","issue":{"url":"https://api.github.com/repos/msgpack/msgpack-java/issues/230","labels_url":"https://api.github.com/repos/msgpack/msgpack-java/issues/230/labels{/name}","comments_url":"https://api.github.com/repos/msgpack/msgpack-java/issues/230/comments","events_url":"https://api.github.com/repos/msgpack/msgpack-java/issues/230/events","html_url":"https://github.com/msgpack/msgpack-java/issues/230","id":80401934,"number":230,"title":"Jackson can't serialize Integer (or basic types)","user":{"login":"fdinoff","id":441141,"avatar_url":"https://avatars.githubusercontent.com/u/441141?v=3","gravatar_id":"","url":"https://api.github.com/users/fdinoff","html_url":"https://github.com/fdinoff","followers_url":"https://api.github.com/users/fdinoff/followers","following_url":"https://api.github.com/users/fdinoff/following{/other_user}","gists_url":"https://api.github.com/users/fdinoff/gists{/gist_id}","starred_url":"https://api.github.com/users/fdinoff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fdinoff/subscriptions","organizations_url":"https://api.github.com/users/fdinoff/orgs","repos_url":"https://api.github.com/users/fdinoff/repos","events_url":"https://api.github.com/users/fdinoff/events{/privacy}","received_events_url":"https://api.github.com/users/fdinoff/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"komamitsu","id":59043,"avatar_url":"https://avatars.githubusercontent.com/u/59043?v=3","gravatar_id":"","url":"https://api.github.com/users/komamitsu","html_url":"https://github.com/komamitsu","followers_url":"https://api.github.com/users/komamitsu/followers","following_url":"https://api.github.com/users/komamitsu/following{/other_user}","gists_url":"https://api.github.com/users/komamitsu/gists{/gist_id}","starred_url":"https://api.github.com/users/komamitsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/komamitsu/subscriptions","organizations_url":"https://api.github.com/users/komamitsu/orgs","repos_url":"https://api.github.com/users/komamitsu/repos","events_url":"https://api.github.com/users/komamitsu/events{/privacy}","received_events_url":"https://api.github.com/users/komamitsu/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-05-25T05:40:07Z","updated_at":"2015-05-30T15:12:26Z","closed_at":"2015-05-30T15:12:11Z","body":"The following fails with an IllegalStateException\r\n\r\n```java\r\nObjectMapper msgPackObjectMapper = new ObjectMapper(new MessagePackFactory());\r\nbyte[] msgPack = msgPackObjectMapper.writeValueAsBytes(1); // Throws\r\n```\r\n\r\n```java\r\ncom.fasterxml.jackson.databind.JsonMappingException: The stack is empty\r\n\tat com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:139)\r\n\tat com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:2881)\r\n\tat com.fasterxml.jackson.databind.ObjectMapper.writeValueAsBytes(ObjectMapper.java:2362)\r\n        ...\r\nCaused by: java.lang.IllegalStateException: The stack is empty\r\n\tat org.msgpack.jackson.dataformat.MessagePackGenerator.getStackTop(MessagePackGenerator.java:371)\r\n\tat org.msgpack.jackson.dataformat.MessagePackGenerator.addValueToStackTop(MessagePackGenerator.java:397)\r\n\tat org.msgpack.jackson.dataformat.MessagePackGenerator.writeNumber(MessagePackGenerator.java:284)\r\n\tat com.fasterxml.jackson.databind.ser.std.NumberSerializers$IntegerSerializer.serialize(NumberSerializers.java:138)\r\n\tat com.fasterxml.jackson.databind.ser.std.NumberSerializers$IntegerSerializer.serialize(NumberSerializers.java:131)\r\n\tat com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:128)\r\n       ...\r\n```\r\n\r\nI would expect the array returned to contain 0x01, which is what `out` would contain if done manually.\r\n\r\n```java\r\nByteArrayOutputStream out = new ByteArrayOutputStream();\r\nMessagePack.newDefaultPacker(out).packInt(1).close();\r\n```\r\n\r\nThis appears to also fail for the other basic types such as booleans, BigInteger, and Strings."},"comment":{"url":"https://api.github.com/repos/msgpack/msgpack-java/issues/comments/107050505","html_url":"https://github.com/msgpack/msgpack-java/issues/230#issuecomment-107050505","issue_url":"https://api.github.com/repos/msgpack/msgpack-java/issues/230","id":107050505,"user":{"login":"komamitsu","id":59043,"avatar_url":"https://avatars.githubusercontent.com/u/59043?v=3","gravatar_id":"","url":"https://api.github.com/users/komamitsu","html_url":"https://github.com/komamitsu","followers_url":"https://api.github.com/users/komamitsu/followers","following_url":"https://api.github.com/users/komamitsu/following{/other_user}","gists_url":"https://api.github.com/users/komamitsu/gists{/gist_id}","starred_url":"https://api.github.com/users/komamitsu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/komamitsu/subscriptions","organizations_url":"https://api.github.com/users/komamitsu/orgs","repos_url":"https://api.github.com/users/komamitsu/repos","events_url":"https://api.github.com/users/komamitsu/events{/privacy}","received_events_url":"https://api.github.com/users/komamitsu/received_events","type":"User","site_admin":false},"created_at":"2015-05-30T15:12:26Z","updated_at":"2015-05-30T15:12:26Z","body":"@fdinoff Thanks for reporting this. I fixed it in https://github.com/msgpack/msgpack-java/pull/243.\r\n\r\nYou can write like this:\r\n```\r\n        ObjectMapper mapper = new ObjectMapper(new MessagePackFactory());\r\n        mapper.disable(JsonParser.Feature.AUTO_CLOSE_SOURCE);\r\n        mapper.disable(JsonGenerator.Feature.AUTO_CLOSE_TARGET);\r\n        PipedOutputStream out = new PipedOutputStream();\r\n        PipedInputStream in = new PipedInputStream(out);\r\n        mapper.writeValue(out, 3.14);\r\n        mapper.writeValue(out, \"hello world\");\r\n        mapper.writeValue(out, 42);\r\n        out.close();\r\n        System.out.println(mapper.readValue(in, new TypeReference<Float>() {}));\r\n        System.out.println(mapper.readValue(in, new TypeReference<String>() {}));\r\n        System.out.println(mapper.readValue(in, new TypeReference<Integer>() {}));\r\n        in.close();\r\n```"}}