@Test public void testThrowIllegalStateException() throws Exception { MessagePack msgpack = new MessagePack(); { ExtendedPacker extpacker = new ExtendedPacker(msgpack); for (int i = 0; i < 511; i++) { Map<String, Object> data = new HashMap<String, Object>(); data.put("ki:" + i, "vi:" + i); data.put("ki:" + i, i); extpacker.write(data); } } { ExtendedPacker extpacker = new ExtendedPacker(msgpack); for (int i = 0; i < 511; i++) { Map<String, Object> data = new HashMap<String, Object>(); data.put("ki:" + i, "vi:" + i); data.put("ki:" + i, i); extpacker.write(data); } Map<String, Object> data = new HashMap<String, Object>(); data.put("ki:" + 511, "vi:" + 511); data.put("ki:" + 511, 511); try { extpacker.write(data); fail(); } catch (Throwable t) { assertTrue(t instanceof IllegalStateException); } } }
synchronized ExtendedPacker write(Map<String, Object> v) throws IOException { packer.writeMapBegin(v.size()); { for (Map.Entry<String, Object> entry : v.entrySet()) { String key = entry.getKey(); if (!keys.contains(key)) { keys.add(key); if (keys.size() == KEY_SOFT_LIMIT) { LOG.warning("Went over soft limit of record keys"); } else if (keys.size() == KEY_HARD_LIMIT) { String msg = "Went over hard limit of record keys"; LOG.severe(msg); throw new IllegalStateException(msg); } } Templates.TString.write(packer, key); packer.write(entry.getValue()); } } packer.writeMapEnd(); rowCount++; return this; }
ExtendedPacker { synchronized ExtendedPacker write(Map<String, Object> v) throws IOException { packer.writeMapBegin(v.size()); { for (Map.Entry<String, Object> entry : v.entrySet()) { String key = entry.getKey(); if (!keys.contains(key)) { keys.add(key); if (keys.size() == KEY_SOFT_LIMIT) { LOG.warning("Went over soft limit of record keys"); } else if (keys.size() == KEY_HARD_LIMIT) { String msg = "Went over hard limit of record keys"; LOG.severe(msg); throw new IllegalStateException(msg); } } Templates.TString.write(packer, key); packer.write(entry.getValue()); } } packer.writeMapEnd(); rowCount++; return this; } }
ExtendedPacker { synchronized ExtendedPacker write(Map<String, Object> v) throws IOException { packer.writeMapBegin(v.size()); { for (Map.Entry<String, Object> entry : v.entrySet()) { String key = entry.getKey(); if (!keys.contains(key)) { keys.add(key); if (keys.size() == KEY_SOFT_LIMIT) { LOG.warning("Went over soft limit of record keys"); } else if (keys.size() == KEY_HARD_LIMIT) { String msg = "Went over hard limit of record keys"; LOG.severe(msg); throw new IllegalStateException(msg); } } Templates.TString.write(packer, key); packer.write(entry.getValue()); } } packer.writeMapEnd(); rowCount++; return this; } ExtendedPacker(MessagePack msgpack); }
ExtendedPacker { synchronized ExtendedPacker write(Map<String, Object> v) throws IOException { packer.writeMapBegin(v.size()); { for (Map.Entry<String, Object> entry : v.entrySet()) { String key = entry.getKey(); if (!keys.contains(key)) { keys.add(key); if (keys.size() == KEY_SOFT_LIMIT) { LOG.warning("Went over soft limit of record keys"); } else if (keys.size() == KEY_HARD_LIMIT) { String msg = "Went over hard limit of record keys"; LOG.severe(msg); throw new IllegalStateException(msg); } } Templates.TString.write(packer, key); packer.write(entry.getValue()); } } packer.writeMapEnd(); rowCount++; return this; } ExtendedPacker(MessagePack msgpack);  }
ExtendedPacker { synchronized ExtendedPacker write(Map<String, Object> v) throws IOException { packer.writeMapBegin(v.size()); { for (Map.Entry<String, Object> entry : v.entrySet()) { String key = entry.getKey(); if (!keys.contains(key)) { keys.add(key); if (keys.size() == KEY_SOFT_LIMIT) { LOG.warning("Went over soft limit of record keys"); } else if (keys.size() == KEY_HARD_LIMIT) { String msg = "Went over hard limit of record keys"; LOG.severe(msg); throw new IllegalStateException(msg); } } Templates.TString.write(packer, key); packer.write(entry.getValue()); } } packer.writeMapEnd(); rowCount++; return this; } ExtendedPacker(MessagePack msgpack);   }