http://git-wip-us.apache.org/repos/asf/ignite/blob/0ac39c97/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/PortableEnumArrayLazyValue.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/binary/builder/PortableEnumArrayLazyValue.java index d6848e9,0000000..fa83d7e mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/PortableEnumArrayLazyValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/PortableEnumArrayLazyValue.java @@@ -1,116 -1,0 +1,115 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.ignite.internal.binary.builder; + +import org.apache.ignite.internal.binary.BinaryWriterExImpl; +import org.apache.ignite.internal.binary.GridPortableMarshaller; +import org.apache.ignite.internal.binary.GridPortableMarshaller; +import org.apache.ignite.internal.binary.BinaryWriterExImpl; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.BinaryInvalidTypeException; + +/** + * + */ +class PortableEnumArrayLazyValue extends PortableAbstractLazyValue { + /** */ + private final int len; + + /** */ + private final int compTypeId; + + /** */ + private final String clsName; + + /** + * @param reader Reader. + */ + protected PortableEnumArrayLazyValue(PortableBuilderReader reader) { + super(reader, reader.position() - 1); + + int typeId = reader.readInt(); + + if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) { + clsName = reader.readString(); + + Class cls; + + try { - // TODO: IGNITE-1272 - Is class loader needed here? - cls = U.forName(reader.readString(), null); ++ cls = U.forName(reader.readString(), reader.portableContext().configuration().getClassLoader()); + } + catch (ClassNotFoundException e) { + throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); + } + + compTypeId = reader.portableContext().descriptorForClass(cls, true).typeId(); + } + else { + compTypeId = typeId; + clsName = null; + } + + int size = reader.readInt(); + + for (int i = 0; i < size; i++) + reader.skipValue(); + + len = reader.position() - valOff; + } + + /** {@inheritDoc} */ + @Override protected Object init() { + reader.position(valOff + 1); + + //skipping component type id + reader.readInt(); + + int size = reader.readInt(); + + PortableBuilderEnum[] res = new PortableBuilderEnum[size]; + + for (int i = 0; i < size; i++) { + byte flag = reader.readByte(); + + if (flag == GridPortableMarshaller.NULL) + continue; + + if (flag != GridPortableMarshaller.ENUM) + throw new BinaryObjectException("Invalid flag value: " + flag); + + res[i] = new PortableBuilderEnum(reader); + } + + return res; + } + + /** {@inheritDoc} */ + @Override public void writeTo(BinaryWriterExImpl writer, PortableBuilderSerializer ctx) { + if (val != null) { + if (clsName != null) + ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, clsName); + else + ctx.writeArray(writer, GridPortableMarshaller.ENUM_ARR, (Object[])val, compTypeId); + + return; + } + + writer.write(reader.array(), valOff, len); + } +}
http://git-wip-us.apache.org/repos/asf/ignite/blob/0ac39c97/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/PortableObjectArrayLazyValue.java ---------------------------------------------------------------------- diff --cc modules/core/src/main/java/org/apache/ignite/internal/binary/builder/PortableObjectArrayLazyValue.java index 537a25f,0000000..7f77b0d mode 100644,000000..100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/PortableObjectArrayLazyValue.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/builder/PortableObjectArrayLazyValue.java @@@ -1,91 -1,0 +1,90 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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. + */ + +package org.apache.ignite.internal.binary.builder; + +import org.apache.ignite.internal.binary.GridPortableMarshaller; +import org.apache.ignite.internal.binary.BinaryWriterExImpl; +import org.apache.ignite.internal.util.typedef.internal.U; +import org.apache.ignite.binary.BinaryInvalidTypeException; + +/** + * + */ +class PortableObjectArrayLazyValue extends PortableAbstractLazyValue { + /** */ + private Object[] lazyValsArr; + + /** */ + private int compTypeId; + + /** */ + private String clsName; + + /** + * @param reader Reader. + */ + protected PortableObjectArrayLazyValue(PortableBuilderReader reader) { + super(reader, reader.position() - 1); + + int typeId = reader.readInt(); + + if (typeId == GridPortableMarshaller.UNREGISTERED_TYPE_ID) { + clsName = reader.readString(); + + Class cls; + + try { - // TODO: IGNITE-1272 - Is class loader needed here? - cls = U.forName(reader.readString(), null); ++ cls = U.forName(reader.readString(), reader.portableContext().configuration().getClassLoader()); + } + catch (ClassNotFoundException e) { + throw new BinaryInvalidTypeException("Failed to load the class: " + clsName, e); + } + + compTypeId = reader.portableContext().descriptorForClass(cls, true).typeId(); + } + else { + compTypeId = typeId; + clsName = null; + } + + int size = reader.readInt(); + + lazyValsArr = new Object[size]; + + for (int i = 0; i < size; i++) + lazyValsArr[i] = reader.parseValue(); + } + + /** {@inheritDoc} */ + @Override protected Object init() { + for (int i = 0; i < lazyValsArr.length; i++) { + if (lazyValsArr[i] instanceof PortableLazyValue) + lazyValsArr[i] = ((PortableLazyValue)lazyValsArr[i]).value(); + } + + return lazyValsArr; + } + + /** {@inheritDoc} */ + @Override public void writeTo(BinaryWriterExImpl writer, PortableBuilderSerializer ctx) { + if (clsName == null) + ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, compTypeId); + else + ctx.writeArray(writer, GridPortableMarshaller.OBJ_ARR, lazyValsArr, clsName); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/0ac39c97/modules/core/src/main/java/org/apache/ignite/internal/processors/platform/PlatformContextImpl.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/0ac39c97/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java ----------------------------------------------------------------------
