Skip to content

Commit

Permalink
Ignite-107 Serialization fix
Browse files Browse the repository at this point in the history
  • Loading branch information
avinogradov committed Jan 21, 2015
1 parent a3149f1 commit 5ed84ec
Showing 1 changed file with 43 additions and 12 deletions.
Expand Up @@ -992,11 +992,11 @@ private <T, R> ComputeJob job(final IgniteClosure<T, R> job, @Nullable final T a
* @return Grid job made out of closure. * @return Grid job made out of closure.
*/ */
@SuppressWarnings("IfMayBeConditional") @SuppressWarnings("IfMayBeConditional")
private ComputeJob job(final Callable<?> c) { private <R> ComputeJob job(final Callable<R> c) {
A.notNull(c, "job"); A.notNull(c, "job");


if (c instanceof ComputeJobMasterLeaveAware) if (c instanceof ComputeJobMasterLeaveAware)
return new C2(c); return new C2<>(c);
else { else {
return new ComputeJobAdapter() { return new ComputeJobAdapter() {
@Override public Object execute() { @Override public Object execute() {
Expand All @@ -1020,11 +1020,11 @@ private ComputeJob job(final Callable<?> c) {
* @return Grid job made out of closure. * @return Grid job made out of closure.
*/ */
@SuppressWarnings(value = {"IfMayBeConditional", "UnusedDeclaration"}) @SuppressWarnings(value = {"IfMayBeConditional", "UnusedDeclaration"})
private ComputeJob job(final Callable<?> c, @Nullable final String cacheName, final Object affKey) { private <R> ComputeJob job(final Callable<R> c, @Nullable final String cacheName, final Object affKey) {
A.notNull(c, "job"); A.notNull(c, "job");


if (c instanceof ComputeJobMasterLeaveAware) if (c instanceof ComputeJobMasterLeaveAware)
return new C3(c,cacheName,affKey); return new C3<>(c,cacheName,affKey);
else { else {
return new ComputeJobAdapter() { return new ComputeJobAdapter() {
/** */ /** */
Expand Down Expand Up @@ -1682,6 +1682,12 @@ private static class C1<T, R> extends GridMasterLeaveAwareComputeJobAdapter {
/** */ /** */
private T arg; private T arg;


/**
*/
public C1(){
// No-op.
}

/** /**
*/ */
public C1(IgniteClosure<T, R> job, T arg) { public C1(IgniteClosure<T, R> job, T arg) {
Expand Down Expand Up @@ -1714,16 +1720,22 @@ public C1(IgniteClosure<T, R> job, T arg) {


/** /**
*/ */
private static class C2 extends GridMasterLeaveAwareComputeJobAdapter { private static class C2<R> extends GridMasterLeaveAwareComputeJobAdapter {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


/** */ /** */
private Callable<?> c; private Callable<R> c;


/** /**
*/ */
public C2(Callable<?> c) { public C2(){
// No-op.
}

/**
*/
public C2(Callable<R> c) {
this.c = c; this.c = c;
} }


Expand All @@ -1749,13 +1761,13 @@ public C2(Callable<?> c) {


/** {@inheritDoc} */ /** {@inheritDoc} */
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
c = (Callable<?>) in.readObject(); c = (Callable<R>) in.readObject();
} }
} }


/** /**
*/ */
private static class C3 extends GridMasterLeaveAwareComputeJobAdapter { private static class C3<R> extends GridMasterLeaveAwareComputeJobAdapter {
/** */ /** */
private static final long serialVersionUID = 0L; private static final long serialVersionUID = 0L;


Expand All @@ -1767,12 +1779,19 @@ private static class C3 extends GridMasterLeaveAwareComputeJobAdapter {
@GridCacheAffinityKeyMapped @GridCacheAffinityKeyMapped
private Object ak; private Object ak;



/** */ /** */
private Callable<?> c; private Callable<R> c;


/** /**
*/ */
public C3(Callable<?> c, @Nullable String cacheName, Object affKey) { public C3(){
// No-op.
}

/**
*/
public C3(Callable<R> c, @Nullable String cacheName, Object affKey) {
this.cn = cacheName; this.cn = cacheName;
this.ak = affKey; this.ak = affKey;
this.c = c; this.c = c;
Expand Down Expand Up @@ -1804,7 +1823,7 @@ public C3(Callable<?> c, @Nullable String cacheName, Object affKey) {
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
cn = (String) in.readObject(); cn = (String) in.readObject();
ak = in.readObject(); ak = in.readObject();
c = (Callable<?>) in.readObject(); c = (Callable<R>) in.readObject();
} }
} }


Expand All @@ -1817,6 +1836,12 @@ private static class C4 extends GridMasterLeaveAwareComputeJobAdapter {
/** */ /** */
private Runnable r; private Runnable r;


/**
*/
public C4(){
// No-op.
}

/** /**
*/ */
public C4(Runnable r) { public C4(Runnable r) {
Expand Down Expand Up @@ -1863,6 +1888,12 @@ private static class C5 extends GridMasterLeaveAwareComputeJobAdapter {
/** */ /** */
private Runnable r; private Runnable r;


/**
*/
public C5(){
// No-op.
}

/** /**
*/ */
public C5(Runnable r, @Nullable String cacheName, Object affKey) { public C5(Runnable r, @Nullable String cacheName, Object affKey) {
Expand Down

0 comments on commit 5ed84ec

Please sign in to comment.